安装使用Window版的nvm-windows,管理nodejs安装

时间:2021-03-25 17:50:23

nvm是一个nodejs的版本管理工具,可以通过nvm安装和切换不同版本的nodejs。

下载

安装包地址:https://github.com/coreybutler/nvm-windows/releases

下载地址提供了两种安装包:

  • nvm-noinstall.zip:绿色免安装版,但使用时需进行配置。
  • nvm-setup.zip:安装版

安装

1、解压nvm-setup.zip包,双击nvm-setup.exe进行安装:

安装使用Window版的nvm-windows,管理nodejs安装

勾选"I accept the agreement",点击“next”:

2、配置NVM的安装路径

安装使用Window版的nvm-windows,管理nodejs安装

3、配置node.js安装路径

安装使用Window版的nvm-windows,管理nodejs安装

点击“Next”,最后安装。


4、【可选】安装完成后,配置node下载的镜像地址。

配置nodejs安装包镜像,目的是加快在国内下载node安装包的速度。

进入nvm安装路径,打开settings.txt,添加淘宝镜像url:

node_mirror: https://npm.taobao.org/mirrors/node/
npm_mirror: https://npm.taobao.org/mirrors/npm/

完整内容类似:

root: D:\program\nvm
path: D:\program\nodejs
node_mirror: https://npm.taobao.org/mirrors/node/
npm_mirror: https://npm.taobao.org/mirrors/npm/

使用

1、查看安装版本

PS D:\mytest> nvm
Running version 1.1.7.
Usage:
nvm arch : Show if node is running in 32 or 64 bit mode.
nvm install <version> [arch] : The version can be a node.js version or "latest" for the latest stable version.
Optionally specify whether to install the 32 or 64 bit version (defaults to system arch).
Set [arch] to "all" to install 32 AND 64 bit versions.
Add --insecure to the end of this command to bypass SSL validation of the remote download server.
nvm list [available] : List the node.js installations. Type "available" at the end to see what can be installed. Aliased as ls.
nvm on : Enable node.js version management.
nvm off : Disable node.js version management.
nvm proxy [url] : Set a proxy to use for downloads. Leave [url] blank to see the current proxy.
Set [url] to "none" to remove the proxy.
nvm node_mirror [url] : Set the node mirror. Defaults to https://nodejs.org/dist/. Leave [url] blank to use default url.
nvm npm_mirror [url] : Set the npm mirror. Defaults to https://github.com/npm/cli/archive/. Leave [url] blank to default url.
nvm uninstall <version> : The version must be a specific version.
nvm use [version] [arch] : Switch to use the specified version. Optionally specify 32/64bit architecture.
nvm use <arch> will continue using the selected version, but switch to 32/64 bit mode.
nvm root [path] : Set the directory where nvm should store different versions of node.js.
If <path> is not set, the current root will be displayed.
nvm version : Displays the current running version of nvm for Windows. Aliased as v.

这个列出了nvm命令的使用说明.


2、列出当前安装的nodejs版本

PS D:\mytest> nvm list
* 12.22.1 (Currently using 64-bit executable)


3、列出可用的安装版本

PS D:\mytest> nvm list available
| CURRENT | LTS | OLD STABLE | OLD UNSTABLE |
|--------------|--------------|--------------|--------------|
| 15.14.0 | 14.16.1 | 0.12.18 | 0.11.16 |
| 15.13.0 | 14.16.0 | 0.12.17 | 0.11.15 |
| 15.12.0 | 14.15.5 | 0.12.16 | 0.11.14 |
| 15.11.0 | 14.15.4 | 0.12.15 | 0.11.13 |
| 15.10.0 | 14.15.3 | 0.12.14 | 0.11.12 |
| 15.9.0 | 14.15.2 | 0.12.13 | 0.11.11 |
| 15.8.0 | 14.15.1 | 0.12.12 | 0.11.10 |
| 15.7.0 | 14.15.0 | 0.12.11 | 0.11.9 |
| 15.6.0 | 12.22.1 | 0.12.10 | 0.11.8 |
| 15.5.1 | 12.22.0 | 0.12.9 | 0.11.7 |
| 15.5.0 | 12.21.0 | 0.12.8 | 0.11.6 |
| 15.4.0 | 12.20.2 | 0.12.7 | 0.11.5 |
| 15.3.0 | 12.20.1 | 0.12.6 | 0.11.4 |
| 15.2.1 | 12.20.0 | 0.12.5 | 0.11.3 |
| 15.2.0 | 12.19.1 | 0.12.4 | 0.11.2 |
| 15.1.0 | 12.19.0 | 0.12.3 | 0.11.1 |
| 15.0.1 | 12.18.4 | 0.12.2 | 0.11.0 |
| 15.0.0 | 12.18.3 | 0.12.1 | 0.9.12 |
| 14.14.0 | 12.18.2 | 0.12.0 | 0.9.11 |
| 14.13.1 | 12.18.1 | 0.10.48 | 0.9.10 |
This is a partial list. For a complete list, visit https://nodejs.org/download/release


4、安装指定版本的nodejs

PS D:\mytest> nvm install 14.16.1
Downloading node.js version 14.16.1 (64-bit)...
Complete
Creating D:\program\nvm\temp
Downloading npm version 6.14.12... Complete
Installing npm v6.14.12...
Installation complete. If you want to use this version, type
nvm use 14.16.1

5、安装最新版的nodejs

PS D:\mytest> nvm install latest 
Downloading node.js version 15.14.0 (64-bit)...
Complete
Creating D:\program\nvm\temp
Downloading npm version 7.7.6... Complete
Installing npm v7.7.6...
Installation complete. If you want to use this version, type
nvm use 15.14.0

6、激活以及切换nodejs版本

PS D:\mytest> nvm use 14.16.1
Now using node v14.16.1 (64-bit)

7、卸载指定版本的nodejs

PS D:\mytest> nvm uninstall 14.16.1
Uninstalling node v14.16.1... done