This blog is intended for developers who are looking to install multiple versions of node on their machine.
If you’re building a web application with any modern framework, chances are you’ll need to install node at some point. Since different projects have different environment setups, you may need to install multiple versions of node on your workstation. As node doesn’t provide any out-of-the-box functionality to have multiple versions of node installed on the same operating system, we'll have to use NVM, which stands for node version manager, to have multiple node versions.
Prerequisites
Before we install multiple node versions via NVM, you will need to uninstall the current node version.
Get the Current Node Version
Keep note of your current installed version of node before you proceed with the uninstallation, as we will need this later. Open cmd with administrator rights and type the following:
node --version
Uninstall Node
Press Windows Key and search for Add or remove programs.
Search node in the search box and click Uninstall by clicking the three dots.
Install NVM
Download nvm-setup.exe from this link. Double-click it and follow the prompts to install NVM, and don't worry; everything remains default, so there is no need to customize anything.
Verify your installation by typing the following command in cmd.
nvm --version
You'll see a version number in the output if your installation succeeds. Otherwise, you'll see node is not recognized as internal command
in the output.
Usage
Remember in the prerequisites that we noted the node version. Well, we will use that now by typing the following
command in cmd to install node. For our example, we had 14.17.0
, so we'll use that.
nvm install 14.17.0
To use the installed version, we type the following in cmd.
nvm use 14.17.0
One more handy command is nvm list
which will display all the installed versions of node on your
workstation. It'll also
tell you which version is currently being used by displaying '🞷' in front of the version number.
Summary
That's it, folks. Now you can have multiple versions of node installed on your machine. To recap, run:
-
nvm install <version>
to install a specified version. -
nvm use <version>
to switch between different versions. -
nvm list
to list all versions installed on your workstation.
Happy decoding!