Node.js version 16 reached End of Life (EOL) on September 11, 2023. Netlify Functions will stop supporting serverless function deploys using Node.js 16 on April 25, 2024.
Who is impacted?
You will be impacted if you have explicitly set the AWS_LAMBDA_JS_RUNTIME
environment variable to nodejs16.x
.
If you keep the environment variable set to nodejs16.x
and deploy any changes to your existing functions on or after April 25, 2024, your build will fail.
If you do not deploy any changes to your functions, they will continue to run; end of support does not impact function execution. However, they will be running on an unsupported runtime that is no longer maintained or patched.
How to upgrade
You can upgrade your Node runtime and avoid build failures in two ways:
- Set
AWS_LAMBDA_JS_RUNTIME
tonodejs20.x
as it is a LTS version. - Remove the
AWS_LAMBDA_JS_RUNTIME
environment variable altogether, in which case we will default to usingnodejs18.x
Test your functions on a new runtime
For many functions, upgrading from Node 16 will have no negative effects. For others, the upgraded version may cause bugs or other errors in your newly deployed functions. So it’s a good idea to test your functions first!
Changing the JavaScript functions runtime applies to all Netlify Functions on a site, in all deploys including production. This makes testing your functions in a new runtime a little trickier than the usual routine of making a PR and checking the Deploy Preview.
Here are a few methods you could use to test without risking errors in production:
-
Run your functions locally in the Netlify CLI using the
netlify dev
command. Whatever version of Node.js you’re running on your computer is the runtime your functions will use locally. You can use a tool like nvm or nvm-windows to manage multiple Node.js versions on your computer. -
Test on Netlify by choosing a different Runtime via context-specific environment variables. You can leave
AWS_LAMBDA_JS_RUNTIME
set tonodejs16.x
for production and set it tonodejs20.x
for deploy previews, branches deployments or even specific branches. Then, trigger a deploy preview or branch deploy and test the functions in that deploy.
Updating your function code
So you’ve tested your functions in a newer runtime, and one of them doesn’t work!
It’s time to start checking error messages and debugging. The problem will often be caused by one or more dependencies, so a useful strategy is to update dependencies related to your error messages, update your functions code as needed to work with the newer version of the dependency, and test again.
Here are a few resources you may find helpful:
Also, always remember the Netlify Forum is here for you! You can ask questions or post additional tips and references in this topic, or start a new topic if it seems significantly different.