Microsoft Azure Open Source Development Support Team Blog

Support for Open Source Technologies on Microsoft Azure App Service

NodeJs and NPM versions on Azure App Services

NodeJs is a JavaScript runtime built on Chrome’s V8 JavaScript engine. NodeJs uses an event-driven, non-blocking I/O model that makes it lightweight and efficient

NPM is the package manager for JavaScript.

How to find the NodeJs version’s that azure web app supports

  • Navigate to kudu console (http://<sitename>.scm.azurewebsites.net) and click cmd in Debug Console
  • Click on disk image and navigate to D:\Program Files (x86)\nodejs
  • You would see all the available versions

NodeJs Version on Azure Apps

There are two ways of setting NodeJs version in azure web Apps

  • Using iisnode.yml (this wont change node version on kudu cli or during deployment)
  • Using App Setting in Azure portal

Note : iisnode.yml would overwrite App Setting if it exists.

NPM Version

NPM version corresponds to the NodeJs version you have set in web app as above.  You do not need to worry about setting the npm version as the version of node you selected (see below) will use the correct npm version.

  • Node 0.12.2  would use npm 2.7.4
  • Node 0.10.32 would use npm 1.4.28

Changing NodeJs Version :

1. Using App Setting

  • Navigate to your web app in azure portal
  • Click on Application settings in Settings blade.
  • You can include WEBSITE_NODE_DEFAULT_VERSION as key and  version of nodejs you want as value in app settings.

Screen Shot 2016-04-20 at 10.32.35 AM

  • Navigate to kudu console (http://<sitename>.scm.azurewebsites.net) and you can check the nodejs version using below command
    • node -v

Screen Shot 2016-04-20 at 10.33.56 AM

Screen Shot 2016-04-20 at 10.37.16 AM

2. Using iisnode.yml file

As i have mentioned earlier, changing nodejs version in iisnode.yml file would only set the run-time environment which iisnode uses. your kudu cmd and others would still use nodejs version set at app settings.

– Setting iisnode.yml file manually

  • Create a iisnode.yml file in your app root folder and include below line

iisnode

nodeProcessCommandLine: "D:\Program Files (x86)\nodejs\5.9.1\node.exe"

– Setting iisnode.yml file using package.json during source control deployment

Azure Source Control deployment process would involve below steps

  1. Moves content to azure web app
  2. Creates default deployment script, if there isn’t one(deploy.cmd, .deployment files) in web app root folder
  3. Run’s deployment script where it creates iisnode.yml file if we mention nodejs version in package.json file > engine
"engines": {
"node": "5.9.1",
"npm": "3.7.3"
}

iisnode.yml would have below line of code

nodeProcessCommandLine: "D:\Program Files (x86)\nodejs\5.9.1\node.exe"

Changing NPM Version

  • Changing NodeJs version would automatically change NPM version
  • If you include npm version in package.json file, that would be used during deployment with source control
"engines": {
"node": "5.9.1",
"npm": "3.7.3"
}

Using Custom Nodejs Version
Azure App services already has most of the NodeJs versions available and the list is constantly updated. If you want to use custom NodeJs version follow below steps

nodeProcessCommandLine: "D:\home\site\wwwroot\node-v4.5.0-win-x86\node.exe"  

Above folder name may change depending on your custom NodeJs version

Output:
App service using custom NodeJs version

Categories

Join the conversation

Add Comment

  1. Vilém Jeniš

    Where or how can I know what are the available versions of npm on my machine?
    I know the available node versions since they are printed out in every deployment log, however npm is just selected but options are not printed-out.