Azure / static-web-apps

Azure Static Web Apps. For bugs and feature requests, please create an issue in this repo. For community discussions, latest updates, kindly refer to the Discussions Tab. To know what's new in Static Web Apps, visit https://aka.ms/swa/ThisMonth
https://aka.ms/swa
MIT License
330 stars 57 forks source link

Support node 20 (or anything > 18.17.1) #1354

Open jlous opened 11 months ago

jlous commented 11 months ago

Please add support for node 20, to keep up with Oryx and the world.

The current version of NextJs is 14, but it is barely possible to deploy: NextJs 14 requires node: '>=18.17.0', but if I specify that in my 'engines' section, Oryx selects 20.0.9, and static-web-apps fails with "Node version 20.9.0 is not supported. Please use one of the following versions 12, 14, 16, 18."

The single node version currently supported by both nextjs 14 and the platform is 18.17.1, and it has to be hard coded all the way But even that tiny window is closing:

Node 18 is entering maintenance mode as we speak (december 2023), and end-of-life in just 5 months. Nextjs release major versions every year, bumping the node requirement past any dead versions.

So this is a ticking bomb for anyone wanting to use new features of fixes in nextjs.

rebeccapeltz commented 11 months ago

Same problem. Here are logs https://github.com/rebeccapeltz/demo-azure-nextjs-client-server-static/actions

michaelmccrae commented 10 months ago

I am encountering the same problem when I try to deploy NextJS on static web apps: You are using Node.js 16.20.2. For Next.js, Node.js version >= v18.17.0 is required.

rafanoronha commented 10 months ago

👍

rafanoronha commented 10 months ago

Hey @thomasgauvin hope u doing great.

Are you guys actually planning to support Node 20?

Tks

thomasgauvin commented 10 months ago

Thanks all for the feedback on this, we'll be looking into this!

thomasgauvin commented 10 months ago

Hi folks, to be clear, this is referring to the runtime Node version being the limitation, not the build time Node version, correct?

rebeccapeltz commented 10 months ago

Here's the log from a failed build : https://github.com/rebeccapeltz/demo-azure-nextjs-client-server-static/actions/runs/7188649410/job/19578699538#step:4:1

rafanoronha commented 10 months ago

Hey @thomasgauvin,

Great news!

On my side, I'm pretty sure this is a runtime limitation indeed.

Looking forward to upgrade two apps into Node 20 🎉

thomasgauvin commented 10 months ago

@rebeccapeltz it appears that your build failed because it built the static & API content with Node 20 when you specified the engines in your package.json, despite Node 20 not yet being supported on SWA. Changing https://github.com/rebeccapeltz/demo-azure-nextjs-client-server-static/commit/7533560861a4553fc637da83f92b72b44a5e07fa from >=18.17.0 to 18.17.0 (or 18.17.1) would fix this, since it would use 18.17.0 instead of Node 20+

@michaelmccrae I would recommend following the specification of the engines in your package.json similarly to what Rebecca did above, specifying an engine of 18.17.0 (or 18.17.1)

@rafanoronha @jlous thanks for the feedback, yes we are looking to adopt Node 20 since it is now in preview in Azure Functions.

rafanoronha commented 10 months ago

Thanks for the update @thomasgauvin 🙏

jugalo1713 commented 10 months ago

thanks @thomasgauvin going to the specific node version in package.json solved my issue:

"engines": {
    "node": "18.17.1"
  }
thomasgauvin commented 9 months ago

Thanks folks for the confirmation, let's keep this issue open until Node 20 rolls out! I will use this thread for any further updates

rebeccapeltz commented 9 months ago

Thanks - it's working for me too. Much appreciated.

yannbolliger commented 9 months ago

Do you have an ETA for node 20 support?

komayama commented 8 months ago

I followed this next.js documentation. By default, Build tools use Node.js 16 and similar error message.

https://learn.microsoft.com/en-us/azure/static-web-apps/deploy-nextjs-hybrid image

And then I tried this method and successfully deploy to SWA. I hope to role out Node.js 20. https://github.com/Azure/static-web-apps/issues/1354#issuecomment-1897671568

thomasgauvin commented 8 months ago

@yannbolliger We don't have a timeline to share at this moment, but it's a work item slotted for our next semester

CyberProgs commented 7 months ago

for me this one worked

"engines": {
    "node": "18.19.1"
}
KasperAndersson commented 7 months ago

@thomasgauvin Do you have a public issue tracker, where the support for Node 20 can be followed - or any eta for the support to land?

marcodali commented 4 months ago

Just add this code block in the azure-static-web-apps-your-id.yml file after actions/checkout@v3 but before Build And Deploy. Final preview:

env:
  NODE_VERSION: '20.x'

jobs:
  build_and_deploy_job:
    runs-on: ubuntu-latest
    name: Build and Deploy Job
    steps:
      - uses: actions/checkout@v3
        with:
          submodules: true
          lfs: false
      - name: Setup Node ${{ env.NODE_VERSION }} Environment
        uses: actions/setup-node@v3
        with:
          node-version: ${{ env.NODE_VERSION }}
      - name: Build And Deploy
        id: builddeploy
        uses: Azure/static-web-apps-deploy@latest