Azure / static-web-apps-cli

Azure Static Web Apps CLI ✨

Home Page:https://aka.ms/swa/cli-local-development

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Node 20 support

itpropro opened this issue · 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.

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/msal-node@1.18.0: The engine "node" is incompatible with this module. Expected version "10 || 12 || 14 || 16 || 18". Got "20.8.1"
error Found incompatible module.

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.

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

#758 (comment)

commented

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

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.

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?

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.

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

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.

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

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.

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.

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.

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

Any updates on this?

Still waiting on this.

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

We've recently released v1.1.10 with Node 20 support. Let us know if this doesn't fix your issue.

@adrianhall This fails for me in Node 20:

$ npx @azure/static-web-apps-cli deploy
Need to install the following packages:
@azure/static-web-apps-cli@1.1.10
Ok to proceed? (y) 

npm error code EBADENGINE
npm error engine Unsupported engine
npm error engine Not compatible with your version of node/npm: @azure/msal-node@1.18.0
npm error notsup Not compatible with your version of node/npm: @azure/msal-node@1.18.0
npm error notsup Required: {"node":"10 || 12 || 14 || 16 || 18"}
npm error notsup Actual:   {"npm":"10.7.0","node":"v20.14.0"}

npm error A complete log of this run can be found in: /Users/atrinh5/.npm/_logs/2024-07-08T08_34_17_471Z-debug-0.log

Hi @tony19 - I also noticed this, caused by @azure/identity v3.x - I've upgraded the @azure/identity to v4.3.0 and that will be released in the next service release (which will actually be v2.0.0 because of a number of underlying breaking changes, most notably - dropping support for node < v18)