23

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
  • 27,273
  • 52
  • 163
  • 280

5 Answers5

31

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"}
Shaun Luttin
  • 133,272
  • 81
  • 405
  • 467
  • 1
    This was helpful they didn't have 6.10.1 when I tried to upgrade but they had 6.10.0 – John Mar 23 '17 at 22:59
  • This worked for me as of 11/3/2017 without the need for a iisnode.yml file. – Papa Stahl Nov 03 '17 at 14:40
  • ... 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. – Papa Stahl Nov 03 '17 at 14:49
  • Works 2 years later ... Thanks a lot for the detailed answer, I wish I could upvote this many times. – margaretkru Jun 11 '18 at 18:37
17

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/

Martin Beeby
  • 4,523
  • 1
  • 26
  • 20
  • This is for running NPM tasks though, will this still work? – JMK Jan 12 '16 at 14:55
  • I used that on my last project. Then when I called node -v it reported the correct node version number. – Martin Beeby Jan 12 '16 at 14:58
  • 1
    Indeed, this should work. Other option is to change the `WEBSITE_NODE_DEFAULT_VERSION` App Setting in the Azure Portal. – David Ebbo Jan 12 '16 at 15:17
  • 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? – BukeMan Dec 11 '17 at 12:26
  • 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. – Asbjørn Ulsberg Jul 16 '21 at 15:54
14

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

Pavel Kovalev
  • 7,521
  • 5
  • 45
  • 67
  • So the accepted answer didn't work? If so, I'll change yours to the accepted one. – JMK Jul 09 '17 at 21:53
  • @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. – Pavel Kovalev Jul 09 '17 at 22:36
  • @PavelKovalev Where did you find iisnode.yml? I haven't found a copy of it that I'm allowed to edit without admin privileges. – Stephen G Tuggy Aug 23 '17 at 00:58
  • @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 – Pavel Kovalev Aug 23 '17 at 05:03
  • 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. https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/iisnode.yml – therightstuff Mar 19 '18 at 14:52
  • ohh....it was life saver.... got tired of all above solution and then scrolled down here.....tha iisnode.yml change worked......:) – pgcan Feb 25 '19 at 05:52
11

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

Daniel Puiu
  • 962
  • 6
  • 21
  • 29
Wlad Neto
  • 351
  • 3
  • 10
0

For me, the solution was neither to set the engine version in package.json, nor to set WEBSITE_NODE_DEFAULT_VERSION, but to use the az command line as described here:

az webapp config set \
  --resource-group <resource-group-name> \
  --name <app-name> \
  --linux-fx-version "NODE|14-lts"
Asbjørn Ulsberg
  • 8,721
  • 3
  • 45
  • 61