安装gnvm,nodejs,npm使用方法
一、安装gnvm
gnvm.exe下载地址:
https://download.csdn.net/download/hsg77/88651752
http://ksria.com/gnvm/#download
二、配置gnvm环境变量
新建目录,如:d:/nodejs 并把gnvm.exe存储到此目录
并把d:/nodejs目录放入到系统path变量中
windows中:
电脑-右键-属性-高级系统设置-环境变量-系统变量-Path-编辑-新建
三、验证
gnvm version
PS D:\nodejs> gnvm version
Current version 0.2.0 64 bit.
Copyright (C) 2014-2016 Kenshin Wang <kenshin@ksria.com>
See https://github.com/kenshin/gnvm for more information.
四、安装node.js版本
注意:cmd或powershell以管理员身份运行
设置TAOBAO映像地址
gnvm config registry TAOBAO
gnvm install 16.20.2
gnvm ls
gnvm use 16.20.2
node -v
v16.20.2
PS D:\nodejs> gnvm install 18.17.0
Start download Node.js versions [18.17.0].
18.17.0: 100% [==================================================>] 12s
--------
End download.PS D:\nodejs> gnvm ls
Notice: gnvm.exe root is D:\nodejs\
v16.20.2 -- global
v18.17.0
v20.10.0
v20.10.0 -- x86PS D:\nodejs> gnvm use 18.17.0
Error: copy D:\nodejs\18.17.0 to D:\nodejs\ folder Error: open D:\nodejs\\node.exe: The process cannot access the file because it is being used by another process..PS D:\nodejs> gnvm use 18.17.0
Set success, global Node.js version is 18.17.0.PS D:\nodejs> gnvm ls
Notice: gnvm.exe root is D:\nodejs\
v16.20.2
v18.17.0 -- global
v20.10.0
v20.10.0 -- x86PS D:\nodejs> gnvm use 16.20.2
Set success, global Node.js version is 16.20.2.PS D:\nodejs> gnvm ls
Notice: gnvm.exe root is D:\nodejs\
v16.20.2 -- global
v18.17.0
v20.10.0
v20.10.0 -- x86node -v
v16.20.2
五:安装npm
gnvm npm global
PS D:\nodejs> node -v
v16.20.2
PS D:\nodejs> gnvm npm global
Notice: local npm version is 10.2.3
Notice: remote npm version is 8.19.4
Notice: download 8.19.4 version [Y/n]? y
Start download new npm version v8.19.4.zip
v8.19.4.zip: 100% [==================================================>] 14s
Start unzip and install v8.19.4.zip zip file, please wait.
Set success, current npm version is 8.19.4.
PS D:\nodejs> npm -v
8.19.4
npm和node的版本是相匹配的,如果不匹配可能会出错。下载的时候不要下载过高的版本(node),也不要过低的版本。
版本参考:https://nodejs.org/en/about/previous-releases
六、搜索node.js的版本列表
gnvm search ..*
gnvm search *.*.*
Search Node.js version rules [*.*.*] from http://npm.taobao.org/mirrors/node/index.json, please wait.
+--------------------------------------------------+
| No. date node ver exec npm ver |
+--------------------------------------------------+1 2023-12-19 21.5.0 x86 x64 10.2.42 2023-12-05 21.4.0 x86 x64 10.2.43 2023-11-30 21.3.0 x86 x64 10.2.44 2023-11-14 21.2.0 x86 x64 10.2.35 2023-10-24 21.1.0 x86 x64 10.2.06 2023-10-17 21.0.0 x86 x64 10.2.07 2023-11-22 20.10.0 x86 x64 10.2.38 2023-10-24 20.9.0 x86 x64 10.1.09 2023-10-13 20.8.1 x86 x64 10.1.010 2023-09-28 20.8.0 x86 x64 10.1.011 2023-09-18 20.7.0 x86 x64 10.1.012 2023-09-07 20.6.1 x86 x64 9.8.113 2023-08-23 20.6.0 x86 x64 9.8.114 2023-08-09 20.5.1 x86 x64 9.8.015 2023-07-19 20.5.0 x86 x64 9.8.016 2023-07-04 20.4.0 x86 x64 9.7.217 2023-06-20 20.3.1 x86 x64 9.6.718 2023-06-08 20.3.0 x86 x64 9.6.719 2023-05-16 20.2.0 x86 x64 9.6.620 2023-05-03 20.1.0 x86 x64 9.6.421 2023-04-17 20.0.0 x86 x64 9.6.422 2023-04-10 19.9.0 x86 x64 9.6.323 2023-03-15 19.8.1 x86 x64 9.5.124 2023-03-14 19.8.0 x86 x64 9.5.125 2023-02-21 19.7.0 x86 x64 9.5.026 2023-02-16 19.6.1 x86 x64 9.4.027 2023-02-01 19.6.0 x86 x64 9.4.028 2023-01-24 19.5.0 x86 x64 9.3.129 2023-01-05 19.4.0 x86 x64 9.2.030 2022-12-14 19.3.0 x86 x64 9.2.031 2022-11-29 19.2.0 x86 x64 8.19.332 2022-11-14 19.1.0 x86 x64 8.19.333 2022-11-04 19.0.1 x86 x64 8.19.234 2022-10-17 19.0.0 x86 x64 8.19.235 2023-11-29 18.19.0 x86 x64 10.2.336 2023-10-13 18.18.2 x86 x64 9.8.137 2023-10-10 18.18.1 x86 x64 9.8.138 2023-09-18 18.18.0 x86 x64 9.8.139 2023-08-08 18.17.1 x86 x64 9.6.740 2023-07-18 18.17.0 x86 x64 9.6.741 2023-06-20 18.16.1 x86 x64 9.5.142 2023-04-12 18.16.0 x86 x64 9.5.143 2023-03-05 18.15.0 x86 x64 9.5.044 2023-02-21 18.14.2 x86 x64 9.5.045 2023-02-16 18.14.1 x86 x64 9.3.146 2023-02-01 18.14.0 x86 x64 9.3.147 2023-01-05 18.13.0 x86 x64 8.19.348 2022-11-04 18.12.1 x86 x64 8.19.249 2022-10-25 18.12.0 x86 x64 8.19.250 2022-10-13 18.11.0 x86 x64 8.19.251 2022-09-28 18.10.0 x86 x64 8.19.252 2022-09-23 18.9.1 x86 x64 8.19.153 2022-09-07 18.9.0 x86 x64 8.19.154 2022-08-24 18.8.0 x86 x64 8.18.055 2022-07-26 18.7.0 x86 x64 8.15.056 2022-07-13 18.6.0 x86 x64 8.13.257 2022-07-06 18.5.0 x86 x64 8.12.158 2022-06-16 18.4.0 x86 x64 8.12.159 2022-06-02 18.3.0 x86 x64 8.11.060 2022-05-17 18.2.0 x86 x64 8.9.061 2022-05-03 18.1.0 x86 x64 8.8.062 2022-04-18 18.0.0 x86 x64 8.6.063 2022-06-01 17.9.1 x86 x64 8.11.064 2022-04-07 17.9.0 x86 x64 8.5.565 2022-03-22 17.8.0 x86 x64 8.5.566 2022-03-17 17.7.2 x86 x64 8.5.267 2022-03-10 17.7.1 x86 x64 8.5.268 2022-03-09 17.7.0 x86 x64 8.5.269 2022-02-22 17.6.0 x86 x64 8.5.170 2022-02-10 17.5.0 x86 x64 8.4.171 2022-01-18 17.4.0 x86 x64 8.3.172 2022-01-10 17.3.1 x86 x64 8.3.073 2021-12-17 17.3.0 x86 x64 8.3.074 2021-11-30 17.2.0 x86 x64 8.1.475 2021-11-09 17.1.0 x86 x64 8.1.276 2021-10-20 17.0.1 x86 x64 8.1.077 2021-10-19 17.0.0 x86 x64 8.1.078 2023-08-08 16.20.2 x86 x64 8.19.479 2023-06-20 16.20.1 x86 x64 8.19.480 2023-03-28 16.20.0 x86 x64 8.19.481 2023-02-16 16.19.1 x86 x64 8.19.382 2022-12-13 16.19.0 x86 x64 8.19.383 2022-11-04 16.18.1 x86 x64 8.19.284 2022-10-12 16.18.0 x86 x64 8.19.285 2022-09-23 16.17.1 x86 x64 8.15.086 2022-08-16 16.17.0 x86 x64 8.15.087 2022-07-07 16.16.0 x86 x64 8.11.088 2022-06-01 16.15.1 x86 x64 8.11.089 2022-04-26 16.15.0 x86 x64 8.5.590 2022-03-17 16.14.2 x86 x64 8.5.091 2022-03-16 16.14.1 x86 x64 8.5.092 2022-02-08 16.14.0 x86 x64 8.3.193 2022-01-10 16.13.2 x86 x64 8.1.294 2021-12-01 16.13.1 x86 x64 8.1.295 2021-10-26 16.13.0 x86 x64 8.1.096 2021-10-20 16.12.0 x86 x64 8.1.097 2021-10-12 16.11.1 x86 x64 8.0.098 2021-10-08 16.11.0 x86 x64 8.0.099 2021-09-22 16.10.0 x86 x64 7.24.0
本blog地址:https://blog.csdn.net/hsg77