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 |
|
and define a default:
1 |
|
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:
- Configure auto-use
- Enabling auto-completion
.nvmrc file🔗
When your project requires a specific version of Node.js, you can indicate it by
creating a .nvmrc
file:
1 |
|
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.