Member-only story
Why and how to use stable node and npm versions across your project & team
I’m a firm believer that development environments should be as stable as possible in order to eliminate discrepancies between environments and among developers. Configurations have a natural tendency to drift when left alone, so it’s best to automate and enforce as many things as possible.
That’s why I consider that Node-based projects should be using a stable and known version of both NodeJS and npm everywhere: to develop locally, to execute the tests, to build the production binaries and to run the application in production.
For project dependencies, this is easy to enforce, as you can list your dependencies in package.json and add the package-lock.json or yarn.lock file to the codebase.
For the version of node itself and npm though, there’s a bit more work to do.
In this article, I’ll explain what steps can be taken to ensure that you use the same/expected versions everywhere.
Project-wide versions for node and npm
The first thing that you can do is to create files at the root of your project (or monorepo) to state the versions to use.
In my monorepo, I have created:
- .npm-version, which only contains 6.14.4