1、下载windows版本的安装包并安装
https://github.com/coreybutler/nvm-windows/releases
2、用管理员身份打开cmd
使用淘宝node镜像:nvm node_mirror
nvm node_mirror https://npm.taobao.org/mirrors/node/
使用淘宝npm镜像:nvm npm_mirror
nvm npm_mirror https://npm.taobao.org/mirrors/npm/
3、安装指定版本的node
nvm install 14.18.2 或 nvm install latest 安装最新版本node
4、切换node版本
nvm use 14.18.2
5、查看node版本
node -v
注意:
有时安装npm会失败,比如提示
Uninstalling node v14.18.2… done
C:\Windows\System32>nvm install 14.18.2
Downloading node.js version 14.18.2 (64-bit)…
Complete
Downloading npm version 6.14.15… Download failed. Rolling Back.
Rollback failed. remove D:\nvm\nvm\temp\npm-v6.14.15.zip: The process cannot access the file because it is being used by another process.
Could not download npm for node v14.18.2.
Please visit https://github.com/npm/cli/releases/tag/v6.14.15 to download npm.
It should be extracted to D:\nvm\nvm\v14.18.2
可以选择去官网手动下载对应的版本,然后将文件全部替换进去