Upgrading Node on an Azure website?

16,664

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.

  1. Go to yoursite.scm.azurewebsites.net
  2. Choose Debug Console (PowerShell or CMD)
  3. Navigate to D:\Program Files (x86)\nodejs
  4. 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 App Service Image

And if you ftp to your App you will see iisnode.yml here:

iisnode.yml on ftp

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

Share:
16,664

Related videos on Youtube

JMK
Author by

JMK

Software developer currently living in Belfast, jack of a couple of trades, master of none!

Updated on July 17, 2021

Comments

  • JMK
    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
    JMK over 8 years
    This is for running NPM tasks though, will this still work?
  • Martin Beeby
    Martin Beeby over 8 years
    I used that on my last project. Then when I called node -v it reported the correct node version number.
  • David Ebbo
    David Ebbo over 8 years
    Indeed, this should work. Other option is to change the WEBSITE_NODE_DEFAULT_VERSION App Setting in the Azure Portal.
  • John
    John about 7 years
    This was helpful they didn't have 6.10.1 when I tried to upgrade but they had 6.10.0
  • JMK
    JMK almost 7 years
    So the accepted answer didn't work? If so, I'll change yours to the accepted one.
  • Pavel Kovalev
    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
    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
    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
    Papa Stahl over 6 years
    This worked for me as of 11/3/2017 without the need for a iisnode.yml file.
  • Papa Stahl
    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
    BukeMan over 6 years
    specifying 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
    therightstuff about 6 years
    iisnode.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
    margaretkru almost 6 years
    Works 2 years later ... Thanks a lot for the detailed answer, I wish I could upvote this many times.
  • Fábio Zangirolami
    Fábio Zangirolami over 5 years
    thankyou my friend!! obrigado amigo ! here brazilian!
  • Bryant
    Bryant over 5 years
    And 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
    pgcan about 5 years
    ohh....it was life saver.... got tired of all above solution and then scrolled down here.....tha iisnode.yml change worked......:)
  • Asbjørn Ulsberg
    Asbjørn Ulsberg almost 3 years
    Changing the engine version in package.json has absolutely no effect for me. When the container boots up it says NodeJS Version : v12.19.0 no matter what I set in engine. Setting WEBSITE_NODE_DEFAULT_VERSION to 14 or v14 also has no effect.