如果安装过node,须得卸载
sudo npm uninstall npm -gsudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*sudo rm -rf /usr/local/include/node /Users/$USER/.npmsudo rm /usr/local/bin/nodesudo rm /usr/local/share/man/man1/node.1sudo rm /usr/local/lib/dtrace/node.d
验证卸载成功
node -v //command not found
npm -v //command not found
1、nvm 官网 操作
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
发现报错
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
网络问题得翻墙,但是我没有墙翻,直接用国内镜像安装
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash -s -- --mirror=https://npm.taobao.org/mirrors/nvm
然后继续报错
继续修复报错
运行下列两条语句
git config --global --unset http.proxy
git config --global --unset https.proxy
然后继续安装,使用淘宝镜像安装,大功告成