Netlify Error: Gatsby requires Node.js xxx or higher

Netlify Error: Gatsby requires Node.js xxx or higher

This post will demonstrate how to update Node and NPM versions in Netlify.

I’ve recently updated my website (www.surinderbhomra.com) from the ground up and when it came to releasing all changes to Netlify, I was greeted by the following error in the build log:

7:39:29 PM: $ gatsby build
7:39:30 PM: error Gatsby requires Node.js 14.15.0 or higher (you have v12.18.0).
7:39:30 PM: Upgrade Node to the latest stable release: https://gatsby.dev/upgrading-node-js

Based on the error, it appears that the Node version installed on my machine is older than what Netlify requires... In fact, I was surprised to discover that it was very old. So I updated Node on my local environment as well as all of the NPM packages for my website.

I now needed to ensure my website hosted in Netlify was using the same versions.

The quickest way to update Node and NPM versions is to add the following environment variables to your site:

NODE_VERSION = "14.15.0"
NPM_VERSION = "8.5.5"

You can also set the Node and NPM versions by adding a netlify.toml file to the root of your website project before committing your build to Netlify:

[build.environment]
    NODE_VERSION = "14.15.0"
    NPM_VERSION = "8.5.5"