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://
.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
-
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.
- Navigate to kudu console (http://
.scm.azurewebsites.net) and you can check the nodejs version using below command - node -v
-
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
- Moves content to azure web app
- Creates default deployment script, if there isn’t one(deploy.cmd, .deployment files) in web app root folder
-
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" }
Update - 01/28/2018 To use the newer npm, you can set WEBSITE_NPM_DEFAULT_VERSION=5.6.0 in your Azure App Settings Source : https://social.msdn.microsoft.com/Forums/en-US/6f0875bb-2cb1-44ce-a50d-effbd4eb34f4/please-install-the-latest-node-with-npm-560-to-solve-a-killer-npm-install-issue?forum=windowsazurewebsitespreview
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
- Download your choice of NodeJs version fromhttps://nodejs.org/en/download/releases/
- While writing this blog, App service doesn’t has NodeJs v4.5
- I have clicked download option at above mentioned link and downloaded “node-v4.5.0-win-x86.zip” from https://nodejs.org/download/release/v4.5.0/
- Move unzipped content to Azure App service
-
Create iisnode.yml file and add below line
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: