Node Version Manager, otherwise known as nvm, is a bash script that simplifies the management of multiple Node.js versions.

To install nvm, use the provided install script:

$ curl -o- <https://raw.githubusercontent.com/creationix/nvm/v0.31.3/install.sh> | bash

For windows there is a nvm-windows package with an installer. This GithHub page has the details for installing and using the nvm-windows package.

After installing nvm, run “nvm on” from command line. This enables nvm to control the node versions.

Note: You may need to restart your terminal for it to recognize the newly installed nvm command.

Then install the latest Node version:

$ nvm install node

You can also install a specific Node version, by passing the major, minor, and/or patch versions:

$ nvm install 6
$ nvm install 4.2

To list the versions available for install:

$ nvm ls-remote

You can then switch versions by passing the version the same way you do when installing:

$ nvm use 5

You can set a specific version of Node that you installed to be the default version by entering:

$ nvm alias default 4.2

To display a list of Node versions that are installed on your machine, enter:

$ nvm ls

To use project-specific node versions, you can save the version in .nvmrc file. This way, starting to work with another project will be less error-prone after fetching it from its repository.

$ echo "4.2" > .nvmrc
$ nvm use
Found '/path/to/project/.nvmrc' with version <4.2>
Now using node v4.2 (npm v3.7.3)