NVM, which stands for “Node.js version manager”, is a tool for managing multiple version of Node.js on an OS, especially for developer. Using nvm, you can install multiple, self-contained versions of Node.js which will allow you to control your environment easier by switching between them. NVM provides you more convenient way to manage and set up your Node.js environment. It will give you on-demand access to the newest versions of Node.js, and also allow you to target previous releases that your application may depend on.
To install NVM, you can clone the nvm repository from the project’s GitHub page:
$ git clone https://github.com/creationix/nvm.git ~/.nvm
Then, we need to add the necessary lines to your ~/.profile file to activate nvm path:
$ echo "source ~/.nvm/nvm.sh" >> ~/.profile
To gain access to the nvm functionality, you’ll need to log out and log in back again, or you can source the ~/.profile file to refresh the current session:
$ source ~/.profile
If you want to see what versions of Node.js are available to install:
$ nvm ls-remote
To install Node.js v0.11.16, you just run:
$ nvm install 0.11.16
If you have multiple Node.js versions, you can see what is installed by typing:
$ nvm ls
You can explicitly tell nvm to use the version we just installed by typing:
$ nvm use 0.11.16
To find out the version currently being used by the shell, you run:
$ node -v
v.0.11.16
Now you can use this version of Node.js as default on your system. To set a default Node version to be used in any new shell, use the alias default:
$ nvm alias default 0.11.16
In different projects you’re using different Node.js versions, then you must go to the project folder, select proper Node.js version with nvm use
v0.11.16
And after that you just need to run “nvm use” and nvm get version from this file.