踩坑-填坑 过程
红字都是 启动台-ohter-终端 里面直接输入就行了
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
brew -v
重启终端
brew uninstall nvm
brew install nvm
成功提示
==> Summary
🍺 /opt/homebrew/Cellar/nvm/0.40.1: 10 files, 202.8KB
重启终端
echo "source $(brew --prefix nvm)/nvm.sh" >> .bash_profile
. ~/.bash_profile
nvm list
nvm install 18.13.0
(卡住不动😅)
// 换源
nvm npm_mirror https://npmmirror.com/mirrors/npm/
nvm node_mirror https://npmmirror.com/mirrors/node/
source ~/.zshrc
重启终端
nvm —version
(报错 zsh: command not found: nvm 😅)
// 解决报错
open ~/.zshrc
// 在最开头加上
source ~/.bash_profile
source ~/.zshrc
重启终端
nvm ls-remote
能拿到版本列表了,但是全是 iojs 😅
// 解决版本列表问题
open ~/.zshrc
// 复制进去保存
export NVM_NODEJS_ORG_MIRROR=https://npmmirror.com/mirrors/node/
export NVM_NPM_ORG_MIRROR=https://npmmirror.com/mirrors/npm/
source ~/.zshrc
重启终端
nvm ls-remote
拿到正常的版本了 e.g. v6.11.1
nvm install 18.13.0
装上啦 😄
.zshrc文件(仅供参考)
source ~/.bash_profile
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
export NVM_NODEJS_ORG_MIRROR=https://npmmirror.com/mirrors/node/
export NVM_NPM_ORG_MIRROR=https://npmmirror.com/mirrors/npm/
每次启动项目都要 nvm use
nvm alias default stable