Node.js version 12 reached End of Life (EOL) on April 30, 2022. Netlify Functions will stop supporting serverless function deploys using Node.js 12 on March 31, 2023.
Who is impacted?
You will be impacted if you have explicitly set the AWS_LAMBDA_JS_RUNTIME
environment variable to nodejs12.x
.
If you keep the environment variable set to nodejs12.x
and deploy any changes to your existing functions on or after March 31, 2023, 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
tonodejs14.x
,nodejs16.x
ornodejs18.x
- Remove the
AWS_LAMBDA_JS_RUNTIME
environment variable altogether, in which case we will default to usingnodejs16.x
Test your functions on a new runtime
For many functions, upgrading from Node 12 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 tonodejs12.x
for production and set it tonodejs18.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:
- Release notes for Node.js v14.0.0
- Release notes for Node.js v16.0.0
- Release notes for Node.js v18.0.0
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.