Read More
🎉Celebrating 25 Years of Tech Excellence and Trust - Learn More
Quick Rundown: Introducing NVM, the Node Version Manager. This powerful tool simplifies your development workflow with easy install, switch, and manage different Node.js versions. In this comprehensive guide, we'll walk you through the step-by-step process of installing NVM on Windows, Linux, Mac, and explore its essential commands. Read on to streamline your Node.js development experience!
As a Node.js developer, I have always preferred the Linux operating system for software development. In fact, I was completely happy and satisfied until I saw how the environment of Node.js works in one of my colleague’s systems - Windows.
Hence, I landed myself buying a new laptop with Windows 10.
Now the first question comes to my mind: How to install Node.js on Windows?
However, being an experienced Node.js developer, I priorly installed Node.js in my various operating systems – Linux and macOS. But installing Node.js for Windows was something new that excited me.
Well, I usually prefer to use Node Version Manager (NVM) to install Node.js.
The actual reason behind choosing NVM for Windows (definitely, in this scenario) is I have to work with multiple applications that require different Node.js versions. Thus, opting to install NVM and using it helps you switch different Node.js versions very easily.
This article is more of a user guide for software engineers who are curious to get an answer to the question – How to install NVM on Windows Operating System?
Bonus Tips: I will explain the steps to install NVM on Linux and install NVM on Mac.
Before getting into the technical details, allow me to walk you through some basic introduction to Node.JS – what is Node.js and the key terminologies of Node.js, and its usage.
Leverage NVM Capabilities to Elevate Your Node.js Journey
Know How
Since the first release of NodeJS in May 2009, NodeJS has become a game changer in the software development industry. It has become the backbone of the modern project. And the current version of Node.js in the market is – Node.js 19 version.
After Java, NodeJS is the second most popular backend technology that startups and enterprises use to build MERN and MEAN, or MEVN stack projects. Moreover, top companies like Uber, Netflix, PayPal, Trello, Yahoo, and others use NodeJS as the primary technology.
If we consider Node.JS, it’s not just another backend technology but also comes with an in-built package manager named NPM (Node Package Manager). The primary use of NPM in all projects is to require external node packages like Angular or ReactJS or Vue.
Build High-performing Applications with Our Expertise in The Best Backend Tech – NodeJS
Leverage Our Services
Node Version Manager (NVM) is a tool to manage different Node versions on your device. Different types of projects on your device may be using different versions of Node. However, you may not get accurate execution results if you use the same version (the one installed by npm
) for these different projects.
For example, if you use a Node version of 10.0.0 for a project that uses 12.0.0, you may encounter some errors. Additionally, you might not get the desired results if you use Node 12.0.0 for a project that is still using Node 10.0.0 after updating it with npm.
In fact, you may get a warning like:
This project requires Node version X
You can use nvm to efficiently manage your node versions for each project rather than npm to install and uninstall Node versions for your various projects.
Depending on the project you're working on, NVM lets you run various Node versions and switch between them using the command line.
I will show you how to install NVM on Windows, Linux, and Mac devices.
If Node.js is already installed on your system, I recommend that you uninstall it to avoid any conflicts with Node.js and nvm.
NVM is mostly supported by Linux and Mac operating systems. It doesn’t provide support for Windows. But you will find a similar tool created by coreybutler to provide an nvm experience in Windows called nvm-windows
.
nvm-windows
comes with a management utility to manage different Node.js versions in Windows.
Here’s how to install it.
nvm-windows
by clicking here.In the latest release (as of the time of writing, it’s 1.1.10), you will find different assets. Click on nvm-setup.exe asset, which is the installation file for the tool.
Now click on the file that you have downloaded and complete the installation process.
Once you are done with the installation process, you can confirm the installation of nvm by executing the below command:
nvm –v
If the nvm was installed correctly, this command will display the nvm version installed.
Note: Don’t change any default configuration. Always click on the Next button.
Go to your command line terminal and write the below command:
$ nvm –version
$ nvm install latest
//installs the latest version of npm
$ nvm install <<version number>>
//e.g. nvm install 12.6.8 to install a specific npm version
Execute the below command to specify the version of npm that you would like to use. Well, in this scenario, we have only one version installed. Let’s go ahead with that.
$ nvm use 14.9.0
By executing the commands below, you can confirm the Nodejs and npm versions.
Check Node.js version
$ node --version
Check npm version
$ npm --version
Planning to Migrate Your Existing Legacy Application to the Latest Node Version?
Hire Node Experts
Repeat the above steps.
Once the installation procedure is completed, select the version using the nvm use
command.
Now you have to make sure that the environment points to the new Node.js and npm versions.
Using the nvm list command, you can list all the npm and Node.js framework versions installed.
$ nvm list
The above-implemented steps helped me to install nvm in Windows system. As promised, I’m going to show how to install NVM on Linux and Mac systems.
Do you know Linux and Mac have some similarities? Actually, they are both UNIX-based operating systems. So, it’s a similar way to install nvm.
Execute the below command in your terminal to run the nvm installer:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
# or
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
Well, you can use curl
or bash
, depending on the command available on your device.
These commands will clone the nvm repository to a ~/.nvm
directory on your device.
The installation process from step 1 should also automatically add the nvm configuration to your profile.
If you use zsh, that would be ~/.zshrc
.
If you use bash, that would be ~/.bash\_profile
…or some other profile.
However, you can add the nvm configuration to your profile file if it doesn’t add automatically.
export NVM\_DIR="$([ -z "${XDG\_CONFIG\_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG\_CONFIG\_HOME}/nvm")"
[ -s "$NVM\_DIR/nvm.sh" ] && \. "$NVM\_DIR/nvm.sh"
The above command loads nvm for use.
Now reload the configuration for your terminal to use when your profile configuration is updated.
source ~/.bashrc
When you run this program, nvm is ready to use. Run the following command to verify that nvm was properly installed:
nvm –v
This shows the version of nvm installed.
Let’s execute the following command and install a particular Nodejs version using nvm
.
nvm install 10.1.0
After executing the above code, Nodejs v10.1.0 will be installed on your system. If Nodejs v14 is in your system, it will not be removed. Instead, nvm will set up Nodejs v10.1.0 to coexist with v14 on my computer. The Node version currently used by the node
was primarily loaded directly, as opposed to through nvm.
You can install as many variations of Node.js as you like:
nvm install 11.2.1
nvm install 16.2.3
Let’s execute the below command to install the latest Node version:
nvm install node
This will install the latest version of Nodejs on your machine.
If we execute the install
command with only the major version, then nvm will install the latest version of Nodejs in that major version.
For example,
nvm install 10
This command will install the latest version of Nodejs v10. Let's say the latest version of Nodejs in major version 10 is 10.19.0. It will be installed.
Get a No Obligation Quote for Your Node JS Development Project
Schedule a Free Call Now
By executing the nvm use command, we can switch Node environments.
nvm use 14
This will switch to Node.js version 14. There must be Nodejs 14 installed in your system before switching to it.
nvm use 12.0.1
This will switch to Nodejs v12.0.1.
The major version of Nodejs will be used by nvm instead of the minor and patch versions if the use
command only specifies the major version.
For example,
nvm use 14
This is the major version – 14. There is no minor or patch version. This will now switch to using the system’s most recent Node version, which has a major version of 14. NVM will select the most recent 14.18.1 version and switch to it if there are Node versions 14.17.1, 14.18.1, and 14.18.0.
nvm
Commands Let’s learn other nvm commands as well:
list
This command lists/displays all the Nodejs versions we have on our machine.
nvm list
Let's see the output:
v14.17.1
v14.18.1
v16.9.0
-> v16.17 system
default -> node (-> v16.17.0)
node -> stable (-> v16.17.0) (default)
stable -> 16.17 (-> v16.17.0) (default)
iojs -> N/A (default)
unstable -> N/A (default)
lts/* -> lts/gallium (-> v16.17.0)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.12 (-> N/A)
lts/fermium -> v14.20.0 (-> N/A)
lts/gallium -> v16.17.0
Check to see that LTS (long-term support) versions and all the Nodejs versions on my system are displayed. You can see that the list entry with the arrow is the most recent Nodejs version.
uninstall
This is the opposite of install
. This command will uninstall a Node version from the system:
nvm uninstall 13.10.1
This will remove the installed Nodejs version 13.10.1 from the system.
run
You can execute a script with a Nodejs version without changing the current version.
nvm run 6.10.3 app.js
This uses node 6.10.3 to execute app.js. Before running the script, you don't need to run the use command to switch the current version to 6.10.3. Consequently, this run command switches before starting the script and switches back to the current version after the script has been run.
ConclusionI hope this detailed user guide on how to install Node Version Manager for Windows, Linux, and Mac helps you set up the NVM.Firstly, we gave you an introduction to Node.js and then followed by nvm. Then we learned about nvm and what it does to Node versions in the system.Next, we discovered how to switch between different Node versions on our computer and the command to do so. Additionally, we learned how to use the nvm tool to load and remove Node versions.Finally, lists of helpful nvm commands appeared, making it easier for us to use the nvm tool.However, it can be difficult to run and manage numerous Node.js versions on the same computer. However, in this user guide, you discovered how to install NVM and manage different Node.js versions on your computer using NVM.So, now that you have figured out how quickly you can switch between different Node.js versions, would you consider NVM to accelerate your workflow? Connect with us and share your views on that. As a prominent Node.Js development company – Radixweb, our experts will be happy to assist you.
Ready to brush up on something new? We've got more to read right this way.