Skip to content

How to Enable Node v18 in Netlify for Gatsby v5

Published: Updated:

I just updated this site to Gatsby v5, but on Netlify I kept getting "Unsupported engine" error (npm WARN EBADENGINE Unsupported engine. It was because Netlify was trying to build the site using Node v16, which ends up failing as Gatsby v5 has Node v18 as a requirement.

Here's how you can change to Node 18 on Netlify:

Screenshot of Netlify environment variable settings with node_version set to 18

Go to your Netlify project deploy settings and find the Environment variables (direct link here). Add NODE_VERSION there with the value 18. You can also specify an exact Node version, such as v18.1.0, but by using just 18 Netlify will automatically choose the recommended v18 version.

Thats it! You will need to do a full cache clear most likely.

Update on 20th of January 2023:

If you have your Gatsby v5 builds failing with Conflicting peer dependency, overriding peer dependency, or Could not resolve dependency, you should add the property --legacy-peer-deps to your Netlify environment variables. You can add it by setting NPM_FLAGS environment variable to --legacy-peer-deps.

Screenshot of Netlify settings with npm_flags set to --legacy-peer-deps