2

I'm running the node server on Azure and need to change the default version of node because it's 0.8.28, or to set the specific version for the app.

At the first time, I thought that I can specify the version using deployment file (deploy.cmd) and package.json like following;

deploy.cmd

:: Force use of the latest NPM
SET NPM_JS_PATH=%ProgramFiles(x86)%\npm\6.12.0\node_modules\npm\bin\npm-cli.js
SET NODE_PATH=%ProgramFiles(x86)%\nodejs\8.9.4\node.exe

package.json

"engines": {
  "node": "8.9.4",
  "npm": "6.12.0"
},

And when the app is deployed, it shows specified versions are set.

2019-12-05T15:36:17    Selected node.js version 8.9.4. Use package.json file to choose a different version.
2019-12-05T15:36:17    Selected npm version 6.12.0
2019-12-05T15:36:17    Updating iisnode.yml at D:\home\site\wwwroot\App_Data\config\scripts\iisnode.yml

That's why I expected the app will be running on node@8.9.4 but when i consoled process.version, it's still 0.8.28. It looks like the version is being overwritten by default version at the end when it's deployed.

Additionally, I tried to edit WEBSITE_NODE_DEFAULT_VERSION variable in Configuration (Settings > Configuration > WEBSITE_NODE_DEFAULT_VERSION) but I couldn't save because the host name doesn't include "azurewebsites.net".

Is there any way to specify the node version or edit WEBSITE_NODE_DEFAULT_VERSION?

Misol Goh
  • 813
  • 6
  • 9

1 Answers1

2

Node Version for your app Kudu needs to know which version of node you want to run your app and deployment. It will try to find the version you want by following these steps. If not satisfied, goes to the next step:

  1. If there is an iisnode.yml and nodeProcessCommandLine property inside: it will run that exact path of node.
  2. If in your package.json, there is an "engines":{"node":version} specification, Azure will use the specified version
  3. In Application Settings on the Azure portal, you have WEBSITE_NODE_DEFAULT_VERSION set as one of the environment variables
  4. The default Node version for Azure. The exact version changes over time.

I think iisnode.yml does not have node version which you require.create iisnode.yml and include below line

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

More deatils read here:

Sandeep Patel
  • 4,815
  • 3
  • 21
  • 37
  • thank you for answering! I tried to all ways above even iisnode.yml and web.config, but I couldn't fix it. I guess changing WEBSITE_NODE_DEFAULT_VERSION is the best way to fix that's why i'm looking for how to edit the hostname which is the reason I can't change that on Configuration. – Misol Goh Dec 09 '19 at 08:25
  • 2
    I had an iisnode.yml file sitting in my ./bin/ folder that was calling a specific version of node from an earlier instance of installation and this was older and different that what we needed. The file was deleted from source code control but remained on the server. It was very difficult to track down and this answer helped immensely. Removing the ./bin/iisnode.yml file allowed Azure to revert to the WEBSITE_NODE_DEFAULT_VERSION and fixed us right up. – Curt Keisler Nov 30 '22 at 22:03