一、安装nvm
下载nvm安装包,window11建议使用exe安装包
Releases · coreybutler/nvm-windows · GitHub
下载后双击安装
切记!切记!切记!
安装nvm和nodejs的目录设置一定不要有特殊符号或者空格,设置一个连续的只有英文的目录
例如:
二、安装nodejs
执行命令:nvm list available 查看可用版本
nvm list available
| CURRENT | LTS | OLD STABLE | OLD UNSTABLE |
|--------------|--------------|--------------|--------------|
| 19.6.0 | 18.14.0 | 0.12.18 | 0.11.16 |
| 19.5.0 | 18.13.0 | 0.12.17 | 0.11.15 |
| 19.4.0 | 18.12.1 | 0.12.16 | 0.11.14 |
| 19.3.0 | 18.12.0 | 0.12.15 | 0.11.13 |
| 19.2.0 | 16.19.0 | 0.12.14 | 0.11.12 |
| 19.1.0 | 16.18.1 | 0.12.13 | 0.11.11 |
| 19.0.1 | 16.18.0 | 0.12.12 | 0.11.10 |
| 19.0.0 | 16.17.1 | 0.12.11 | 0.11.9 |
| 18.11.0 | 16.17.0 | 0.12.10 | 0.11.8 |
| 18.10.0 | 16.16.0 | 0.12.9 | 0.11.7 |
| 18.9.1 | 16.15.1 | 0.12.8 | 0.11.6 |
| 18.9.0 | 16.15.0 | 0.12.7 | 0.11.5 |
| 18.8.0 | 16.14.2 | 0.12.6 | 0.11.4 |
| 18.7.0 | 16.14.1 | 0.12.5 | 0.11.3 |
| 18.6.0 | 16.14.0 | 0.12.4 | 0.11.2 |
| 18.5.0 | 16.13.2 | 0.12.3 | 0.11.1 |
| 18.4.0 | 16.13.1 | 0.12.2 | 0.11.0 |
| 18.3.0 | 16.13.0 | 0.12.1 | 0.9.12 |
| 18.2.0 | 14.21.2 | 0.12.0 | 0.9.11 |
| 18.1.0 | 14.21.1 | 0.10.48 | 0.9.10 |
This is a partial list. For a complete list, visit https://nodejs.org/en/download/releases
安装需要的版本
一般选择LTS长期支持版
执行命令
nvm install 18.14.0
Downloading node.js version 18.14.0 (64-bit)...
Extracting node and npm...
Complete
npm v9.3.1 installed successfully.
Installation complete. If you want to use this version, type
nvm use 18.14.0
选择启用node版本
这里安装了两个版本,使用nvm的好处就是可随时切换版本,管理起来很方便
执行:nvm use 18.14.0
C:\Users\groot>nvm list
18.14.0
16.19.0
C:\Users\groot>nvm use 18.14.0
Now using node v18.14.0 (64-bit)
C:\Users\groot>nvm list
* 18.14.0 (Currently using 64-bit executable)
16.19.0
C:\Users\groot>
三、安装nrm管理镜像仓库
安装nrm
每个版本的node需要单独安装nrm
C:\Users\groot>npm install -g nrm
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
added 58 packages in 3s
查看可用镜像仓库
C:\Users\groot>nrm ls
npm ---------- https://registry.npmjs.org/
yarn --------- https://registry.yarnpkg.com/
tencent ------ https://mirrors.cloud.tencent.com/npm/
cnpm --------- https://r.cnpmjs.org/
taobao ------- https://registry.npmmirror.com/
npmMirror ---- https://skimdb.npmjs.com/registry/
设置远程仓库为淘宝镜像仓库
C:\Users\groot>nrm use taobao
Registry has been set to: https://registry.npmmirror.com/
查看是否生效
C:\Users\groot>npm config get registry
https://registry.npmmirror.com/