What is nvm?

Node Version Manager (nvm) is a tool that allows you to manage multiple versions of Node.js on the same machine. Each version runs in its own isolated environment, so you can safely switch versions without affecting the whole system.

It is the Node.js equivalent of Ruby’s rvm and rbenv.

Installing nvm

Start by running the install script using cURL:

curl https://raw.githubusercontent.com/creationix/nvm/v0.24.0/install.sh | bash

Note: As at the time of writing, 0.24.0 is the latest version of nvm. Check the latest release before installing.

The script installs nvm to ~/.nvm, inside your home directory. It also adds a line to your profile (~/.bash_profile, ~/.zshrc or ~/.profile depending on which shell you use).

The nvm command will be available when you restart your shell, or immediately if you source your profile manually:

source ~/.bashrc # or ~/.zshrc or ~/.profile

Make sure nvm is installed correctly by running:

nvm --version

This command should print out the installed version of nvm.

Installing Node.js

Install the latest stable release of Node.js with the following command:

nvm install stable

Replace stable with a version number to install a specific version.

Select the installed version in any new shell using:

nvm use stable

Now you can use different versions of Node.js in each of your shell instances. But if you want to set the latest version as default for any new shell, run:

nvm alias default stable

Make sure Node.js is installed correctly by checking the version:

node -v

For more nvm commands run nvm help or see the Usage section in the README.