nitrojs / nitro

Next Generation Server Toolkit. Create web servers with everything you need and deploy them wherever you prefer.
https://nitro.build
MIT License
6.16k stars 507 forks source link

Clamp to valid Vercel Node versions #2819

Open cjpearson opened 3 days ago

cjpearson commented 3 days ago

Describe the feature

The Vercel preset currently sets its runtime node version based on the version of node used to build the application. https://github.com/unjs/nitro/blob/v2/src/presets/vercel/utils.ts#L19 This caused an issue when updating from Node 20 to 22 (the LTS recently changed) because Vercel does not support Node 22.

What do you think about clamping the value to valid versions? So if you build with v22 or v23, v20 will be used as the default for the runtime?

Alternatively, maybe follow the same rules as Vercel does with the engine field? I was originally a bit confused with the invalid runtime error because I assumed those rules would apply (and we have >= 20 in our engines), but Nitro setting the runtime takes precedence.

Additional information