nvm安裝node
一、安裝nvm
linux安裝
- 編輯文件/etc/hosts
199.232.68.133 raw.githubusercontent.com
199.232.68.133 user-images.githubusercontent.com
199.232.68.133 avatars2.githubusercontent.com
199.232.68.133 avatars1.githubusercontent.com
新增上面這一步的目的是為了避免出現“0curl: (7) Failed connect to raw.githubusercontent.com:443; Connection refused” 這個錯誤。
- 下載nvm及安裝
cd /data
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
# 大概率是下載不下來的,可以到我的百度云盤下載后直接執行,路徑見下圖
bash install.sh
- 修改環境變量及刷新環境變量
在環境變量內追加vi /root/.bashrc
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
- 查看驗證是否安裝成功
查看nvm是否安裝成功
nvm
刷新`/root/.bashrc`文件
```shell
source /root/.bashrc
windows安裝
在地址https://github.com/coreybutler/nvm-windows/releases中找到nvm-setup.exe,下載雙擊安裝即可
二、安裝node
使用nvm選擇安裝node版本及激活與設置鏡像
# 查看已經安裝的node版本
nvm list
# 查看有哪些版本可以安裝
nvm list available
# 選擇指定的版本號進行安裝,如
nvm install 13.14.0
# 激活指定node
nvm use 13.14.0
# 查看node版本,npm -v
node -v
# 查看鏡像地址,默認為https://registry.npmjs.org
npm config get registry
# 修改鏡像地址為淘寶的
npm config set registry https://registry.npm.taobao.org
參考
1.當指定依賴下載不下來的時候,參考博客http://www.rzrgm.cn/TheoryDance/p/17309687.html
2.直接安裝指定版本的nodejs,參考博客http://www.rzrgm.cn/TheoryDance/p/16056240.html

浙公網安備 33010602011771號