Serverless functions don't work with Node 22?

I got an email from Vercel about a project that still uses Node 18, which is going to be sunset soon, saying that I should upgrade to Node 22. So I did, by changing the setting in the Vercel UI. The next deployment with this new setting failed with this message:

Error: The following Serverless Functions contain an invalid “runtime”

The message linked to this page, but that hasn’t been updated since Jan 2024 and doesn’t refer to Node 22 at all.

The project just has two Node.js serverless functions under the api/ folder, without a framework (no Next.js). Is it a known issue that these simply don’t work with Node 22? I couldn’t find anything in the documentation about that.

(I then changed my project setting to Node 20 and deploying with that worked fine.)

It could be a package dependency requiring a different Node.js version. In that case you should the function(s) listed below that error message. If there are any older packages imported, you may need to upgrade those as well.

But I’m not really sure about all the possible causes and solutions for this one. Let me ask the team if they have other ideas. And I’ll let them know about the outdated guide link as well

1 Like

Thanks for the reply. I don’t think it’s a package dependency, because I’ve been running the same code locallly on Node 23 without any issues.