Why NVM is Tremendously Helpful for Web Developers
If you are working on Node.js ecosystem then probably you’ve heard about node version manager or NVM.
Today, we will see why this exists and why you should care about learning it.
What is NVM?
According to the official docs,
nvm allows you to quickly install and use different versions of Node.js via the command line.
Apart from that, it also keeps you away from many errors.
The problem at hand
Ever encountered the EACCESS error when you tried to install some global npm package?
npm install -g some-packageI bet you have! But what’s the solution? Some StackOverflow answers will suggest you use sudo . Which is a very very bad idea and can lead you to more problems.
The official npm docs suggest that we use node version manager (nvm) to resolve this issue.
Install NVM
If you are using Linux run the following command:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bashIf it’s successful you can check the version:
command -v nvmYou may have to close your terminal and reopen it again.
Install the Latest Version of Node.js
If we want to install the latest version of the node we can run the following command:
nvm install nodeAt the time of writing this article, the latest version of the Node.js is v17.3.0.
Install Specific Version of Node.js
At the time of writing this article, the latest version of Node.js is 16.13.1 . If we want to install this specific version:
nvm install 16.13.1Check the installed versions
If you want to see the list of versions installed on your machine run the following command:
nvm lsThis will show the versions on your machine.

Use a specific version of the node
Now let’s say you have multiple versions of the node installed on your machine. And you want to switch between them. Maybe you want to work on a legacy app that uses Node.js 14.
You can just run:
nvm use 14You can check the version of the node by running the following command:
node -vAnd now you are using Node 14.

Install the Latest Version of npm
You can install the latest version of npm for the version run the following command:
nvm install-latest-npmAnd check the version:
npm --versionSo essentially you can have multiple versions of npm on your machine now!

How cool is that?
Final Notes
These tools are here to make our lives easier. Let’s take full advantage of them.
Hope you learned something new today. Have a great day!
Have something to say? Get in touch with me via LinkedIn

