Using nvm on Windows

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:
Insert image description here

Right click and run install.cmd as administrator
Insert image description here

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.
Insert image description here

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

  1. Check nvm version
nvm -v

Insert image description here

  1. List node.js installations
nvm list

Insert image description here

  1. Show the currently used version
nvm current

Insert image description here

  1. 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

Insert image description here

For example, install the latest current version

nvm install latest

Insert image description here

  1. 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

Insert image description here

For example using the latest current version

nvm use latest

Insert image description here

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

Insert image description here

  1. Uninstall node.js version
nvm uninstall <version>
<version>:可以是具体版本号,也可以是"latest"表示最新当前版本,也可以是"lts"表示最新的LTS版本

Insert image description here

  1. For more commands, please view the official documentation nvm-windows#usage

Guess you like

Origin blog.csdn.net/sywdebug/article/details/132764085
NVM