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.
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.
1 | 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 18.17.0
, so we’ll use that.
1 | nvm install 18.17.0 |
To use the installed version, we type the following in cmd.
1 | nvm use 18.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.
1 | PS E:\htdocs> nvm list |
Summary
That’s it. 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.nvm list available
to list all versions available for installation.
Happy decoding!