從這里拷貝
https://github.com/nvm-sh/nvm/blob/v0.40.0/install.sh
粘貼到腳本
vi install_nvm.sh
bash install_nvm.sh
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 換源
vi ~/.nvm/nvm.sh
NVM_NODEJS_ORG_MIRROR="https://npmmirror.com/mirrors/node/"
export NVM_NODEJS_ORG_MIRROR=https://npmmirror.com/mirrors/node/
# 或者
nvm npm_mirror https://npmmirror.com/mirrors/npm/
nvm node_mirror https://npmmirror.com/mirrors/node/
npm換源
# 設(shè)置
npm config set registry https://registry.npmmirror.com/
# 還原
npm config set registry https://registry.npmjs.org/