nvm安装和使用
# NVM安装和使用
# 1 nvm安装
步骤1:Github下载
步骤2:开始安装,需要设置安装目录
步骤3:这里一定要是空文件夹或者不存在的文件夹,安装时会自动创建
步骤4:测试安装是否成功,输入命令nvm -v
。看到以下内容说明安装成功,下面显示了一些常用命令。
Running version 1.1.9.
Usage:
nvm arch : Show if node is running in 32 or 64 bit mode.
nvm current : Display active version.
nvm install <version> [arch] : The version can be a specific version, "latest" for the latest current version, or "lts" for the
most recent LTS 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 use "latest", "lts", or "newest".
"newest" is the latest installed 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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 2 nvm配置
# 配置镜像
下面设置镜像加速,打开nvm安装路径中的settings.txt
配置文件
在最下方添加两行配置:
node_mirror:https://npm.taobao.org/mirrors/node/
npm_mirror:https://npm.taobao.org/mirrors/npm/
1
2
2
# 3 下载Node
下面选择16.15.1版本进行安装
输入安装命令:nvm install 16.15.1
,可以看到安装了node并且下载了该版本node对应版本的npm包。
使用该版本:nvm use 16.15.1
(这里需要使用管理员模式打开CMD)
安装完成后看到nvm安装目录下出现了v16.15.1文件夹
# 4 nvm常用命令
- nvm list:查看当前已经安装的node版本
- nvm use [version]:使用某版本
- nvm install [version]:安装某版本
- nvm on:开启node版本管理
- nvm off:关闭node版本管理
编辑 (opens new window)
上次更新: 2022/07/16, 23:51:27