Npm timeout when deploying Node.js app to azure app service using yarn

Photo by Markus Spiske on Unsplash

I was trying to deploying a Node.js app to azure app service recently but it kept timing out trying to download all the required modules.

I was able to fix this by specifying an explicit network timeout for the npm install in my azure-pipelines.yaml file

This really helps on the lower app service tiers because they are quite slow.

The network timeout is specified in the last part of this task.

- task: AzureRmWebAppDeployment@4
    inputs:
      ConnectionType: 'AzureRM'
      azureSubscription: '$(azureSubscription)'
      appType: 'webAppLinux'
      WebAppName: '$(serverWebAppName)'
      packageForLinux: '$(System.ArtifactsDirectory)/drop/$(Build.BuildId).zip'
      RuntimeStack: 'NODE|10.16'
      StartupCommand: 'cd server && node dist/index.js'
      ScriptType: 'Inline Script'
      InlineScript: |
        cd server
        yarn install --production --network-timeout=30000

Hey! Are you a developer?

🚀 Set Up Your Dev Environment in Minutes, Not Hours!

Tired of spending hours setting up a new development machine? I used to be, too—until I automated the entire process!

Now, I just run a single script, grab a coffee, and let my setup take care of itself.

Save 30+ hours configuring a new Mac or Windows (WSL) development environment.
Ensure consistency across all your machines.
Eliminate tedious setup and get coding faster!
Get Instant Access →