nvm是node的版本管理工具
在windows下安裝nvm-windows,下載地址 https://github.com/coreybutler/nvm-windows/releases
選擇下載 nvm-setup.zip
安裝好后會設置環境變量
驗證是否安裝成功
說明:
由於之前安裝的v12.16.3,把此版本加入了,但是安裝完nvm后node版本卻成了v10.15.3,因此卸載了之前的版本
1.配置
找到默認安裝目錄 C:\Users\Bei\AppData\Roaming\nvm 下的 settings.txt
配置系統位數
配置鏡像
root: C:\Users\Bei\AppData\Roaming\nvm path: C:\Program Files\nodejs arch: 64 proxy: none node_mirror: http://npm.taobao.org/mirrors/node/ npm_mirror: https://npm.taobao.org/mirrors/npm/
2.安裝node
安裝v12.16.3
>nvm install v12.16.3 Downloading node.js version 12.16.3 (64-bit)... Complete Creating C:\Users\Bei\AppData\Roaming\nvm\temp Downloading npm version 6.14.4... Complete Installing npm v6.14.4... Installation complete. If you want to use this version, type nvm use 12.16.3
查看
>nvm list 12.16.3
使用
>nvm use v12.16.3 Now using node v12.16.3 (64-bit) >node -v v12.16.3 >npm -v 6.14.4
安裝v14.15.4
C:\Windows\system32>nvm install v14.15.4 Downloading node.js version 14.15.4 (64-bit)... Complete Creating C:\Users\Bei\AppData\Roaming\nvm\temp Downloading npm version 6.14.10... Complete Installing npm v6.14.10... Installation complete. If you want to use this version, type nvm use 14.15.4
查看與版本切換
>nvm list 14.15.4 * 12.16.3 (Currently using 64-bit executable) >nvm use v14.15.4 Now using node v14.15.4 (64-bit) >nvm list * 14.15.4 (Currently using 64-bit executable) 12.16.3 >node -v v14.15.4 >npm -v 6.14.10
注:
node版本可以去官網查看
如果使用git bash執行node命令,需要獲取管理員權限,才能使選擇的版本生效