Skip to content

NVM

NVM is Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions.

Use it if you work on Javascript projects directly on your host (for performances reasons for instance) instead of inside a VM / Docker where the proper Node version should already be configured.

Installation🔗

Refer to the official guide

Note

The official documentation states that the Homebrew installation is not officially supported. If you have issues with homebrew-installed NVM, run brew uninstall nvm and follow the guide above.

Tip

You can also simply install it as a Zsh plugin following the instructions below.

Start by installing some common versions:

1
2
3
nvm install 14
nvm install 12
nvm install 10

and define a default:

1
nvm alias default 12

Zsh plugin🔗

NVM can be installed as a plugin using zsh-nvm. Follow instructions in this guide to install it.

This plugin manages the NVM installation, provides autocompletion & auto-use feature to automatically switch to the proper Node.js version to run for a project.

Some interesting resources:

.nvmrc file🔗

When your project requires a specific version of Node.js, you can indicate it by creating a .nvmrc file:

1
v10.24

indicates the projet should be run using a v10.24 Node.js version.

When such a file is available in your project directory structure, running nvm use will automatically read the file and switch to the right version. If the version isn't installed yet, you may run nvm install.

If you installed the Zsh plugin and enabled auto-use, the proper Node.js version will be switched to whenever you browse to a project with a .nvmrc file.


Last update: December 20, 2024