NVM (Node Version Manager) is a tool for managing and switching multiple Node.js versions. It allows you to install and use different versions of Node.js simultaneously on the same machine without having to install and uninstall manually.
In the past, only one version of node.js was installed, which was updated every time. This made the old projects unable to run because the versions of node.js and npm were too high, so nvm was used to install and manage multiple versions of node.js.
Github warehouse address: nvm-windows
Install
Download a zip package that requires no installation, or an exe installer.
Use zip to directly unzip and install
After decompression, the compressed package contains the following files:
Right click and run install.cmd as administrator
Enter the absolute path of the decompressed directory, like here I amE:\nvm-noinstall
After pressing Enter, the setting.txt file used to run the nvm command will be automatically generated in the decompression directory, and the decompression directory will be added to the environment variable.
root: 代表nvm存放node.js不同版本文件的目录
path: 代表创建软连接的文件夹
arch: 代表节点运行在32位架构还是64位架构
proxy: 代表用于下载的代理
Install using exe installer
I won’t talk about the installation using the exe installer. Just run the installation directly. After the installation is completed, the setting.txt file used to run the nvm command will be automatically generated and the installation directory will be added to the environment variable.
Common commands
- Check nvm version
nvm -v
- List node.js installations
nvm list
- Show the currently used version
nvm current
- Install node.js version
nvm install <version> [arch]
<version>:可以是特定版本,也可以是"latest"表示最新当前版本,也可以是"lts"表示最新的LTS版本
[arch]:可选安装32位或64位,也可以为"all"两个都安装,默认是setting.txt文件指定的架构
在命令结尾添加`--insecure`可以绕过远程下载服务器的SSL验证
Here are some examples. The first two prompt that node.js is installed successfully, but npm installation fails. You can download it yourself according to the link prompted, and then put it under the installed node.js version in the nvm directory.
For example, install the last version of v14 ``` nvm install v14 or nvm install 14 ``` ![Insert picture description here](https://img-blog.csdnimg.cn/7500340a3d764fed8ad068ac0cd41da0.png#pic_center)For example, install a specific version v14
nvm install v14.17.0 或 nvm install 14.17.0
For example, install the latest current version
nvm install latest
- Use node.js version
nvm use <version> [arch]
<version>:可以是特定版本,也可以是"latest"表示最新当前版本,也可以是"lts"表示最新的LTS版本
[arch]:可选32位或64位,默认是setting.txt文件指定的架构
Here are some examples
For example, use the last version of v14 ``` nvm use v14 or nvm use 14 ``` ![Insert picture description here](https://img-blog.csdnimg.cn/319303be0f4a4419a623170ef0060a7c.png#pic_center)For example, use v14 specific version
nvm use v14.17.0 或 nvm use 14.17.0
For example using the latest current version
nvm use latest
For example, if I use the latest LTS version, I have not installed it here, so I will be prompted that it is not installed, and the version used will not be changed.
nvm use lts
- Uninstall node.js version
nvm uninstall <version>
<version>:可以是具体版本号,也可以是"latest"表示最新当前版本,也可以是"lts"表示最新的LTS版本
- For more commands, please view the official documentation nvm-windows#usage