DEV Community

Samira Awad
Samira Awad

Posted on

How to install Node.js, NPM and NVM on Windows (node version manager)

1. Introduction:
Each language has its own version manager. For Node.js, we use NVM (Node Version Manager), which allows us to work with multiple versions of Node.js in the same environment. This is useful for testing our developments on different versions of Node.js, which is a good practice recommended by both npm and Microsoft.

2. Key Concepts:
NPM: Node.js Package Manager.
NVM: Node.js Version Manager.

3. Preparations:
Before installing NVM, we must ensure that there is no previous version of Node.js installed on our system to avoid conflicts. To check this, run in the terminal:
node -v

4. NVM installation:
• For macOS and Linux: Visit the official NVM repository on GitHub (nvm-sh/nvm).
• For Windows: Download NVM from the following link:

  • Click "Download Now".
  • Download the nvm-setup.zip file.
  • Unzip the file and run the installer.
  • During installation, leave all the default options, since NVM has an update tool that will allow us to easily manage versions.

5.Verify NVM installation:
Once installed, open a new terminal and verify that NVM is correctly installed by running:
nvm

6.Install a version of Node.js:
NVM allows you to install specific versions of Node.js or the latest version. To install the latest recommended version (LTS), run:
nvm install lts

To install others: nvm install version

7.List installed versions of Node.js:
To view the versions of Node.js installed on your system, use:
nvm list

8.Use a specific version of Node.js:
Open a terminal with administrator permissions and choose the version of Node.js you want to use:
nvm use 16.13.1
(Replace 16.13.1 with the version you want.)

9.Check the version of Node.js in use:
To check which version of Node.js is active, run:
node -v
You can also check the current version of Node.js handled by NVM with:
nvm current

10.Uninstall a version of Node.js:
If you want to uninstall a version of Node.js, open the terminal with administrator permissions and run:
nvm uninstall 16.13.1
(Replace 16.13.1 with the version you want to remove.)

11.Installing NPM and Yarn:
When you install Node.js with NVM, npm is installed automatically. To check the npm version, use:
npm -v
If you prefer to use Yarn, install it for each version of Node.js you use:
npm install -g yarn

Conclusion:
With NVM, you can easily manage multiple versions of Node.js on a single system, allowing you to easily test in different environments.

Image description

Top comments (0)