2.1 NVM
What is NVM?
Node Version Manager (NVM), as the name implies, is a tool for managing Node versions on your device.
Different projects on your device may be using different versions of Node. Using only one version (the one installed by npm) for these different projects may not give you accurate execution results.
For example, if you use a Node version of 10.0.0 for a project that uses 12.0.0, you may get some errors. And if you update the Node version to 12.0.0 with npm, and you use it for a project that uses 10.0.0, you may not get the expected experience.
In fact, you would most likely get a warning that says:
This project requires Node version X
Instead of using npm to install and uninstall Node versions for your different projects, you can use nvm, which helps you effectively manage your node versions for each project.
NVM allows you to install different versions of Node, and switch between these versions depending on the project that you’re working on via the command line.
Before proceeding, uninstall Node.js
if you have it installed already so that you do not have any conflicts with Node.js
and nvm.
NVM on windows
NVM is mostly supported on Linux and Mac. It doesn’t have support for Windows. But there’s a similar tool created by coreybutler to provide an nvm experience in Windows called nvm-windows.
- Click on “Download Now” In the nvm-windows repository Readme, click on “Download Now!”:
- Install the .exe file of the latest release In the latest release (which as of the time of writing this is 1.1.9), you’ll find different assets. Click on the nvm-setup.exe asset which is the installation file for the tool:
- Complete the Installation Wizard Open the file that you have downloaded, and complete the installation wizard.
When done, you can confirm that nvm has been installed by running:
nvm -v If nvm was installed correctly, this command will show you the nvm version installed.
After installation:
With nvm installed, you can now install, uninstall, and switch between different Node versions in your Windows, Linux, or Mac device.
This command will install the last version of Node:
nvm install latest
This will install the X.Y.Z Node version.
nvm install vX.Y.Z
You can also make a version your default by running:
nvm alias default vX.Y.Z
And if you want to use a specific version at any point, you can run the following in your terminal:
nvm use vA.B.C
NVM makes it easier to manage multiple versions of Node.js
across different projects that require different versions.