Detailed explanation of how to use nvm to manage multiple versions of Node.js

Table of contents

NVM performs NodeJS multi-version management

background

installation steps

 1. Download nvm installation package

2. Install nvm

Steps for usage

Download nodejs

Switch version nodejs

Edit

Common commands


NVM performs NodeJS multi-version management

background

Sometimes the development environment requires multiple NodeJS versions. In this case, NVM can be used to manage them.

installation steps

 1. Download nvm installation package


Official download address: http:// https://github.com/coreybutler/nvm-windows/releases ​

It is recommended to download nvm-setup.zip. Some download tutorials may recommend that you download nvm-noinstall.zip. I have tried this. Noinstall does not need to be installed after downloading, but you have to configure the setting.txt file and environment variables yourself. On the contrary, it is more troublesome.

The nvm-setup.zip installation can directly help us configure the environment variables and settings. We only need to install it in the next step.

2. Install nvm

After downloading and decompressing, it will be an exe directly:
Insert image description here
select the path for nvm installation.

 

This is to select the nodejs installation path. I didn’t quite understand this path when I first installed it, and I’ll explain it later.

 After installation, you will find that the environment variables are automatically configured. Let me briefly mention here, why installing some software requires configuring the environment variable git. The role of environment variables is to run related commands in any folder or file path.

If you have installed nodejs before installing nvm you need

 

Steps for usage

Query version number: Need to open as administrator 

View nodejs hosted  nvm ls

Download nodejs

I just installed nvm and found that neither node nor npm can be used. The reason is that we only installed nvm. nvm helps us manage nodes. It cannot replace node. Next we install node. To install node, you only need to enter the command to install it.

View currently installed nodejs through nvm

 If you get an error when downloading nodejs, please read another blog to configure it.

https://blog.csdn.net/xm1037782843/article/details/131404502?spm=1001.2014.3001.5502

Switch version nodejs

Common commands


nvm ls // View the currently installed version
nvm install 10.5.0 // Install the specified version of nodejs
nvm use 10.5.0 // Use the specified version of nodejs
nvm list available // Display a partial list of downloadable versions
nvm uninstall 10.5 .0 //Delete the installed specified version, the syntax is similar to install
nvm alias //Add aliases to different version numbers
nvm unalias //Delete the defined alias
`nvm reinstall-packages <version>` //In the current version node Environment, re-install the npm package with the specified version number globally
nvm current //Display the current version
 

Guess you like

Origin blog.csdn.net/xm1037782843/article/details/131412270