//

NODEJS INSTALL WITH NVM

Node Version Manager is a simple bash script to manage multiple active node.js versions. In this article, we are going to discuss about managing NodeJS install with NVM.

Why NVM?

At any given time, you could be working with different projects, some using the older version of NodeJS and other recent. NVM enables us to install different versions for different projects.

Installing NVM

You do have to have at least one version of node and npm to get started, but after that you can install nvm with npm.

You can install NVM as a script using cURL:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash

Or you can also use Wget:

wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash

You might have to change the version, check Github for the latest version.

You might have to close and reopen your terminal to start using NVM.

Install Node using NVM

Let's look at how we can use NVM to install Node now. Before downloading a specific version of Node, you can find which versions are available for you to download.

nvm ls-remote

You can install the version you desire with the following command:

nvm install 5.0

And then in any new shell just use the installed version:

nvm use 5.0

Using NVM

You can check which version of NVM is installed with the following command:

nvm ls

If you are only using one version of Node, you can set it as default.

nvm alias default 5.0

When you are using multiple projects, you can tell which version to be used by creating .nvmrc file inside the directory.

Conclusion

Managing versions is crucial but tedious. The task should be automated. NVM helps us manage multiple Node Js versions without a sweat. It becomes much easy to work in a working version, and try something new in the latest version. All you have to do is nvm use default and nvm use stable.