Skip to content

feat: set default (runtime) Node.js version - #2794

Closed
luc122c wants to merge 22 commits into
nitrojs:mainfrom
luc122c:feat/default-runtime-node-version
Closed

luc122c wants to merge 22 commits into
nitrojs:mainfrom
luc122c:feat/default-runtime-node-version

Conversation

@luc122c

@luc122c luc122c commented Oct 13, 2024

Copy link
Copy Markdown
Contributor

🔗 Linked issue

Closes #2716

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

A preset should accept the user's choice of Node.js runtime, as long as it is supported by the platform. In cases where the user's choice is not supported, or the user does not specify a runtime, a sensible default/fallback should be used.

Currently, the fallback is defined per preset. However, to ensure all deploy providers behave uniformly, we should define this globally at the Nitro level.

See #2654 (comment) for reference.

Methodology

To decide an appropriate fallback, we need to know two pieces of information:

  • Node versions supported by the platform
  • How to define a runtime from a node version

To do this, we can export a getDefaultNodeVersion utility which takes the supported Node versions as a set of numbers, and a function to convert the number to a runtime defintion. It then compared this to a globally set default. As Nitro is updated and newer Node features are used, this global can be increased to bump all presets.

Examples

const supportedNodeVersions = new Set([18, 20]);
const defineRuntime = (version) => `nodejs-${version}`;

const default = getDefaultNodeVersion(supportedNodeVersions, defineRuntime);
const supportedNodeVersions = new Set([16, 18, 20]);
const default = getDefaultNodeVersion(supportedNodeVersions, String);

Considerations

This utility should consider the case where the Nitro default is not supported by the platform yet.

The documentation for preset authors should be updated to only list GA node versions in supportedNodeVersions.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@luc122c

luc122c commented Oct 13, 2024

Copy link
Copy Markdown
Contributor Author

Hi @pi0 I have written up my idea and implemented it into a couple of presets. Before I continue and implement it into others, I thought it would be wise to seek some feedbadk.

What do you think of the idea? Do you think the utilities and constants are located in the right places? Is there anything else you would like me to consider?

@vercel

vercel Bot commented Jul 15, 2025

Copy link
Copy Markdown

@luc122c is attempting to deploy a commit to the Nitro Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Jul 15, 2025 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nitro.build ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 15, 2025 4:09pm

@pi0

pi0 commented Jul 15, 2025

Copy link
Copy Markdown
Member

Hi dear @luc122c i love this idea sorry i couldn't check earlier. Please let me back on this, perhaps we can introduce in v3 branch first (also we should drop 16, 18 :D)

@luc122c

luc122c commented Jul 15, 2025

Copy link
Copy Markdown
Contributor Author

@pi0 no problem at all! I forgot about it too 😆

Yes, I will target the v3 branch, make 20 the minimum and try to finish it off. Thanks for your support :)

@luc122c
luc122c changed the base branch from v2 to v3 July 15, 2025 18:58
@luc122c
luc122c force-pushed the feat/default-runtime-node-version branch 2 times, most recently from 49414b7 to 97546a4 Compare July 17, 2025 19:42
@luc122c

luc122c commented Jul 17, 2025

Copy link
Copy Markdown
Contributor Author

Well, this rebase has turned into a great big mess 😆 I might close this and start a new branch and cherry-pick the relevant commits.

@luc122c

luc122c commented Jul 17, 2025

Copy link
Copy Markdown
Contributor Author

It looks like Nitro no longer needs to specify the node version in the preset for Firebase App Hosting. The buildpack picks it up from package.json.

@luc122c

luc122c commented Jul 27, 2025

Copy link
Copy Markdown
Contributor Author

@pi0 I have refactored the function to take the node version in package.json into consideration. I have also applied it to all applicable presets.

I've tried to make it as simple as possible to apply this to other presets. Is there anywhere you'd like me to write any documentation for this?

@luc122c
luc122c marked this pull request as ready for review July 27, 2025 22:19
@luc122c
luc122c requested a review from pi0 as a code owner July 27, 2025 22:19
@Rothalack

Copy link
Copy Markdown

This has become much more relevant since Sept 23 when AWS Amplify dropped support for Node 18. The temporary work around I have found is this:
https://repost.aws/questions/QUlWLs6Z1lSTG791VP-Hf3XA/nuxt-vue-app-stopped-deploying-sep-23-2025-with-error-message-customererror-we-failed-to-validate-the-deploy-manifest-json-file-found-in-your-build-output-directory

It would be great if we could have a way to change the automatically generated deploy-manifest that is currently defaulting to node 18 with Nuxt 3. (Hopefully this is the correct place to make this request)

@pi0

pi0 commented Nov 6, 2025

Copy link
Copy Markdown
Member

This PR is targetting nitro v3 (upcoming nuxt) i will review ASAP.

@Rothalack If AWS needs a hotfix please feel free to make a PR against v2 branch for it specifically we can land it sooner.

@Rothalack

Copy link
Copy Markdown

Thanks for the quick reply @pi0

I did a deeper dive through things before I went making a PR, making sure I really understood everything.

I was on Nuxt 3.17.2, which uses Nitro 2.11.11, which defaults to Node 18. I found that Nuxt 3.2, uses Nitro 2.12.9, which defaults to Node 20. Effectively doing exactly what I was hoping to find. So I think what I was asking for has already been solved.

Thanks!

@pi0x pi0x added the enhancement New feature or improvement (PRs; issues use the Feature type) label Sep 2, 2026
@pi0x pi0x changed the title feat: default (runtime) Node.js version feat: set default (runtime) Node.js version Sep 2, 2026
@pi0x pi0x added the v3 label Sep 2, 2026
@pi0x

pi0x commented Sep 7, 2026

Copy link
Copy Markdown
Contributor
  • I looked at rebasing this, but did not push anything. The branch is about 1000 commits behind main and 4 of the 5 files conflict. Fixing them would mean rewriting the PR, not rebasing, so it is better if you redo it.
  • The idea is still wanted. Default (runtime) Node.js version #2716 is open and main still has three separate implementations (Vercel, Azure, Amplify).
  • Things that changed since: the Node lists here (18/20/22) are old. main now uses 20/22/24 for Vercel, 20/22 for Azure, 20/22/24 for Amplify.
  • Two points worth agreeing with a maintainer first: today Vercel picks the lowest supported version at or above the build machine's Node, and this PR drops that. Also engines.node is usually a range like >=20, and Number.parseInt(">=20") is NaN, so the lookup will rarely match.

This comment was written by an AI assistant on behalf of the Nitro maintainers. Please double-check anything that looks wrong.

@pi0

pi0 commented Oct 13, 2026

Copy link
Copy Markdown
Member

Thanks for the PR and sorry for late reply ❤️

Closing as it seems stalled now.

@pi0 pi0 closed this Oct 13, 2026
@luc122c

luc122c commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

@pi0 Yeah, no problem. It think if this was to be implemented now, it would need a different solution to the one in the PR.

@luc122c
luc122c deleted the feat/default-runtime-node-version branch October 13, 2026 19:58
@pi0x pi0x removed the v3 label Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or improvement (PRs; issues use the Feature type)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default (runtime) Node.js version

4 participants