Home > Web Front-end > JS Tutorial > body text

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

PHPz
Release: 2024-08-29 11:45:01
Original
414 people have browsed it

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

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.

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

The above is the detailed content of How to install Node.js, NPM and NVM on Windows (node version manager). For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template