Azure / static-web-apps-cli

Azure Static Web Apps CLI ✨
https://aka.ms/swa/cli-local-development
MIT License
583 stars 110 forks source link

Node 20 support #756

Closed itpropro closed 4 days ago

itpropro commented 8 months ago

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.

johnnyreilly commented 8 months ago

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.
johnnyreilly commented 8 months ago

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 commented 8 months ago

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

jhelmink commented 7 months ago

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

itpropro commented 7 months ago

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.

bzbetty commented 7 months ago

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?

aaronpowell commented 7 months ago

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 commented 7 months ago

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

itpropro commented 6 months ago

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.

aaronpowell commented 6 months ago

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

jcpachkoski commented 4 months ago

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.

josephboyd9 commented 3 months ago

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.

avalanchis commented 3 months ago

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.

chrisred commented 3 months ago

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

donniefitz2 commented 2 months ago

Any updates on this?

redanthrax commented 1 month ago

Still waiting on this.

bzbetty commented 1 month ago

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

adrianhall commented 4 days ago

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