Upgrading Node on an Azure website?
Solution 1
You can specify the version of node that the app is running on using the package.json file. Add:
"engines":{"node":version}
e.g.:
"engines":{"node": "0.12.x"},
More info: https://azure.microsoft.com/en-us/documentation/articles/nodejs-specify-node-version-azure-apps/
Solution 2
Ensure the Azure Web App has the node version you want.
- Go to yoursite.scm.azurewebsites.net
- Choose Debug Console (PowerShell or CMD)
- Navigate to
D:\Program Files (x86)\nodejs
- Run
dir
to see the available nodejs versions.
For instance, if there is a directory named 6.3.0
, then you can use it.
// App Setting
WEBSITE_NODE_DEFAULT_VERSION 6.3.0
// package.json
engines":{"node": "6.3.0"}
Solution 3
2017 update. All above didn't work for me in.
I changed:
// package.json
engines":{"node": "8.0.0"}
and then I added app settings value
<appSettings>
<add key="WEBSITE_NODE_DEFAULT_VERSION" value="8.0.0" />
</appSettings>
I restarted an app million times, and the solution was to change iisnode.yml
nodeProcessCommandLine: "D:\Program Files (x86)\nodejs\8.0.0\node.exe"
That's it. I hope it will help someone.
Update
Just to clarify things: I'm talking about App Service
And if you ftp to your App you will see iisnode.yml here:
Solution 4
Changing NodeJs Version in Azure Portal
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.
Example: WEBSITE_NODE_DEFAULT_VERSION 8.0.0
Related videos on Youtube
JMK
Software developer currently living in Belfast, jack of a couple of trades, master of none!
Updated on July 17, 2021Comments
-
JMK almost 3 years
I'm trying to run some pre deployment tasks (unit tests etc) with NPM on an Azure website, however the version of node on the VM is v0.10.32, the current version of node is v4.2.4.
I have non administrative access to the command line via the SCM website, no RDP etc.
Is there any way to upgrade?
-
JMK over 8 yearsThis is for running NPM tasks though, will this still work?
-
Martin Beeby over 8 yearsI used that on my last project. Then when I called node -v it reported the correct node version number.
-
David Ebbo over 8 yearsIndeed, this should work. Other option is to change the
WEBSITE_NODE_DEFAULT_VERSION
App Setting in the Azure Portal. -
John about 7 yearsThis was helpful they didn't have 6.10.1 when I tried to upgrade but they had 6.10.0
-
JMK almost 7 yearsSo the accepted answer didn't work? If so, I'll change yours to the accepted one.
-
Pavel Kovalev almost 7 years@JMK no, it didn't work for me. Maybe they changed stuff since that time, I'm not sure. But other settings didn't change anything until I changed iisnode.yml. Maybe that happens because I didn't specify node version initially so it defaulted to v0.10 which not supported by many plugins as of today.
-
Stephen G Tuggy over 6 years@PavelKovalev Where did you find iisnode.yml? I haven't found a copy of it that I'm allowed to edit without admin privileges.
-
Pavel Kovalev over 6 years@StephenGTuggy I updated my answer and added a few pictures. So you have to FTP to your App Service so you can see iisnode.yml
-
Papa Stahl over 6 yearsThis worked for me as of 11/3/2017 without the need for a iisnode.yml file.
-
Papa Stahl over 6 years... for a node.js angular app. I used VSTS for both the git repository, build and release. The build is using Visual Studio 2017 hosted, npm to install angular and node, command line for the ng build. It is based on the npm with Gulp VSTS build template. The release just grabs the artifact and pushes it to Azure.
-
BukeMan over 6 yearsspecifying the node version using the package.json file does not seem to work when deploying through VSTS. Is there a way to make it work?
-
therightstuff about 6 yearsiisnode.yml is an optional file that overrides settings from your web.config file. this means that because you have it, it must point to the correct node executable but for everyone else it's not necessarily the correct answer. github.com/tjanczuk/iisnode/blob/master/src/samples/…
-
margaretkru almost 6 yearsWorks 2 years later ... Thanks a lot for the detailed answer, I wish I could upvote this many times.
-
Fábio Zangirolami over 5 yearsthankyou my friend!! obrigado amigo ! here brazilian!
-
Bryant over 5 yearsAnd make sure the version you set it to is supported. You can get the list of versions by following this answer: stackoverflow.com/a/45515422/10893
-
pgcan about 5 yearsohh....it was life saver.... got tired of all above solution and then scrolled down here.....tha iisnode.yml change worked......:)
-
Asbjørn Ulsberg almost 3 yearsChanging the
engine
version inpackage.json
has absolutely no effect for me. When the container boots up it saysNodeJS Version : v12.19.0
no matter what I set inengine
. SettingWEBSITE_NODE_DEFAULT_VERSION
to14
orv14
also has no effect.