~/dejafu/blog/nvmrc
Created a month ago
Last changed a month ago

Manage Node versions across repositories

A simple yet very effective method to communicate the Node version to contributors of a repository is the use of .nvmrc.

.nvmrc

It is a file that you keep along with your repository. It is intended for the Node Version Manager (nvm), which can parse that file and automatically set up the Node.js version accordingly.

I don't want to repeat and paraphrase anything, which is already very well documented, so please refer to the official documentation, which can be found here: https://github.com/nvm-sh/nvm?tab=readme-ov-file#nvmrc

Why is it important to use the correct Node version?

When installing a Node project using npm install, the package-lock.json file will differ when using different Node.js versions. To keep the installation and build process consistent across repositories, I highly recommend the use of the .nvmrc file.

For a given repository, if contributors use different Node versions to compile the project and if the package-lock.json file is version controlled, this would lead to different package-lock.json files, hence the necessity to regenerate the file!

If not aware, the application would still run, when executed in dev mode, for instance, but very possibly would not behave as intended due to artifacts resulting from the differing Node version.

Thanks for checking in. See you next time!

~ jacky