'Azure Static Web Apps: How to set the version of Node.js?
I want to use Node.js v12.x to build and deploy but it uses 14.15.1:
Using Node version:
v14.15.1
Using Npm version:
6.14.8
Solution 1:[1]
You can set the desired node.js version via the Azure CLI:
az webapp config set --resource-group <resource-group-name> --name <app-name> --linux-fx-version "NODE|12.X"
For more information, see https://docs.microsoft.com/de-de/azure/app-service/configure-language-nodejs?pivots=platform-linux#set-nodejs-version
Solution 2:[2]
If you arrived here wanting to set the Node.js runtime version that is used for your API backend, refer to https://docs.microsoft.com/en-us/azure/static-web-apps/configuration#platform
In summary, you will create a staticwebapp.config.json
that sits where your app_location
is pointed in your github workflow (typically the root of your project) or any subfolder of app_location
You can then set the runtime like this...
{
"platform": {
"apiRuntime": "node:16"
}
}
At the time of writing, your options are node:12
, node:14
, node:16
. Reference the link above for the most up to date values.\
I'd like to answer the original question as well because I think the accepted answer is wrong. The azure CLI will say that az webapp ...
can't find your project because it's a staticwebapp
not a webapp
.
The solution (and I'm not certain) should be to set the nodeEngines
in package.json
, like this:
{
"engines": {
"npm": ">=7.0.0",
"node": ">=16.0.0"
},
"dependencies": {
...
}
}
If I'm wrong about this, let me know in the comments and I'll update it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Tobias Thieron |
Solution 2 |