Specifying a Node version

In your build instructions for Node apps (https://docs.netlify.com/configure-builds/manage-dependencies/#node-js-and-javascript), the recommended way to set a Node version is via a .node-version file or NODE_VERSION env var; and similarly use NPM_VERSION to set the npm version, and YARN_VERSION to set the yarn version.

The standard way to define these (in any Node project) is via the engines key in package.json – see https://docs.npmjs.com/files/package.json#engines

The approach you’re using can lead to a situation where the Node, npm and/or yarn versions used on the developer’s machine are not the same as in a Netlify build, leading to build failures or strange variation.

Don’t Repeat Yourself – this info should be in only one place. It would be better to use the package.json mechanism. If that can’t be done, it would make sense to add a prominent warning to your doc page that I referenced about to say the standard Node approach is IGNORED.

Thanks for bringing this up, @chris-activewrite. We’ll think it over!

Hey Chris!

Really appreciate you taking the time to write this up so thoughtfully! We have an open feature request on this:

If you could add your voice to it there, then you’ll see if we get it implemented automatically :slight_smile: