[Support Guide] Tips for upgrading your Netlify Functions from Node.js v8.10

Node.js version 8 reaches End of Life (EOL) on December 31, 2019. AWS Lambda, the service behind Netlify Functions, will stop supporting serverless function deploys using Node.js 8 on January 6, 2020.

What does this mean for you?

If you created your site after December 4, 2019, or you have set your site to use a custom Node.js version at 10 or above, nothing. Functions on these sites are already using a newer version of Node.js, and won’t be affected by the change on January 6.

However, if you have Netlify Functions in JavaScript running on a site created before December 4, 2019, and you have not set your JS runtime to Node.js 10 or above, your new and updated functions deployed on or after January 6, 2020 will now deploy with the Node.js version 12. (Functions in previous deploys will continue to run exactly as they were deployed.)

For many functions, upgrading from version 8 to 12 will have no effect, and they’ll continue to run fine. 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!

Test your functions on a new runtime

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 locking your deploys and updating the functions runtime. With your deploys locked, you can test your functions on any deploy without the risk of accidentally deploying a change to production. You can set the functions runtime to any 10.x or 12.x version supported by AWS Lambda, then trigger a branch deploy and test the functions in that deploy. If you need to deploy to production while you’re testing, you can set the runtime back to version 8.x before unlocking deploys.
  • Test on Netlify by creating a new test site from your existing repo. This works a lot like the previous option, but with a bit less risk and possibly less hassle. If you want to use Node.js 12, you don’t even have to set the runtime, since new sites use version 12 by default. You can still set the runtime if you want to use version 10, or a more specific version of 12.x.

Updating your 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 Community 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.

1 Like