static-web-apps-cli icon indicating copy to clipboard operation
static-web-apps-cli copied to clipboard

Node 20 support

Open itpropro opened this issue 2 years ago • 15 comments

If the staticwebapp.config.json file contains

  "platform": {
    "apiRuntime": "node:20"
  },

The following error message will appear:

[swa] WARNING: Failed to read staticwebapp.config.json configuration from:
[swa]    /YOURAPP/staticwebapp.config.json
[swa]
[swa] The following error was encountered: must be equal to one of the allowed values dotnet:3.1, dotnet:6.0, dotnet-isolated:6.0, dotnet-isolated:7.0, node:12, node:14, node:16, node:18, python:3.8, python:3.9, python:3.10
[swa] 0: {
[swa] 1:     "platform": {
[swa] 2:         "apiRuntime": "node:20"
[swa] 3:     },
[swa]
[swa] Please fix the above error and try again to load and use the configuration.
[swa] Read more: https://aka.ms/swa/config-schema

Node 20 is the current release since march and will be LTS in 4 days, so swa should support it.

Update: Node 20 is now the LTS version of Node, 18 is only receiving security fixes and 16 is EOL.

itpropro avatar Oct 20 '23 15:10 itpropro

There is a different issue when running with Node.js 20. The @azure/identity dependency in turn depends upon "@azure/msal-node" "^1.17.3" which triggers the following message on install:

error @azure/[email protected]: The engine "node" is incompatible with this module. Expected version "10 || 12 || 14 || 16 || 18". Got "20.8.1"
error Found incompatible module.

johnnyreilly avatar Oct 23 '23 17:10 johnnyreilly

If you're using yarn you can hack using a newer version of @azure/msal-node that is Node.js v20 compatible using a resolutions entry in your package.json:

  "resolutions": {
    "**/@azure/msal-node": "2.3.0"
  },

However it looks like Node.js 20 isn't generally supported anyway

✖ Found Azure Functions Core Tools v4 which is incompatible with your current Node.js v20.8.1. ✖ See https://aka.ms/functions-node-versions for more information.

johnnyreilly avatar Oct 23 '23 18:10 johnnyreilly

There's some discussion on this PR around Node.js 20 support - linking in case it becomes useful.

https://github.com/Azure/static-web-apps-cli/pull/758#issuecomment-1776682070

johnnyreilly avatar Oct 24 '23 07:10 johnnyreilly

Until Azure Functions support Node.js v20 isn't this a bit moot? They only just released v18 to public preview.

jhelmink avatar Nov 09 '23 04:11 jhelmink

Until Azure Functions support Node.js v20 isn't this a bit moot? They only just released v18 to public preview.

They released the public preview of Node 20 support on September 27th and they stated themselves that it is later than they wished, but the GA process is a little bit tedious and they plan to release into GA the latest March 2024. But as azure-functions-core-tools and the whole tooling already supports Node 20, it should definitely be supported by static-web-apps-cli and the Static Web Apps Azure Service. Node 20 is the current LTS and Node 18 is already in maintenance since October and people started to migrate away from it.

itpropro avatar Nov 11 '23 17:11 itpropro

For those of us that use .NET as our functions backend I'm not sure why we even get this error? Is there a way to disable this check?

bzbetty avatar Nov 16 '23 19:11 bzbetty

For those of us that use .NET as our functions backend I'm not sure why we even get this error? Is there a way to disable this check?

The reason that you get this error with .NET Functions is the CLI tool used to start Azure Functions (azure-functions-core-tools) is a node package.

aaronpowell avatar Dec 05 '23 03:12 aaronpowell

I've opened a PR, #786, which should fix this.

aaronpowell avatar Dec 05 '23 03:12 aaronpowell

Do you have any updates on node 20 for the CLI or the runtime @aaronpowell ? All our projects are using the current LTS version or Node, which is 20 and SWA is the only tooling that still doesn't support it.

itpropro avatar Jan 02 '24 00:01 itpropro

Do you have any updates on node 20 for the CLI or the runtime @aaronpowell ? All our projects are using the current LTS version or Node, which is 20 and SWA is the only tooling that still doesn't support it.

The PR is up for review by the team, that's the extent of what I know

aaronpowell avatar Jan 02 '24 04:01 aaronpowell

I've been trying the same. I have node.js v20.11.0. I was hoping this was fixed by now. Found Azure Functions Core Tools v4 which is incompatible with your current Node.js v20.11.0.

jcpachkoski avatar Feb 22 '24 00:02 jcpachkoski

Any update on this yet? Azure Functions have now been updated to support Node.js v20, but swa still doesn't allow them to work together.

josephboyd9 avatar Mar 11 '24 02:03 josephboyd9

As a temporary workaround, I was able to edit the installed source on my workstation.

I found the file in this folder: C:\Users\username\AppData\Roaming\npm\node_modules\@azure\static-web-apps-cli\dist\core\func-core-tools.js

I edited the file to match the changes in the PR that @aaronpowell posted above: #786

Seems to be working for me.

avalanchis avatar Mar 15 '24 15:03 avalanchis

I would like this fixed too. Did as @avalanchis suggested and it works fine.

chrisred avatar Mar 17 '24 10:03 chrisred

Any updates on this?

donniefitz2 avatar Apr 05 '24 16:04 donniefitz2

Still waiting on this.

redanthrax avatar May 09 '24 17:05 redanthrax

The PR works fine and can be applied with patch-package. Not ideal but it's an ok work around.

bzbetty avatar May 09 '24 19:05 bzbetty