[node]mac卸载并重装nodejs以及推荐nvm安装

参考: https://stackoverflow.com/questions/11177954/how-do-i-completely-uninstall-node-js-and-reinstall-from-beginning-mac-os-x

brew uninstall node
# or `brew uninstall --force node` which removes all versions
brew cleanup
sudo 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/.npm
sudo rm /usr/local/bin/node
sudo rm /usr/local/share/man/man1/node.1
sudo rm /usr/local/lib/dtrace/node.d

 

以下方法废弃


brew install node

这里会有坑,会说link连接不了

Error: The 'brew link' step did not complete successfully

这时需要

brew doctor

检查一下

又会发现Brew doctor says: “Warning: /usr/local/include isn't writable.”

sudo chown -R $(whoami) $(brew --prefix)/*

给予权限

在重新链接

brew link --overwrite node
which node

发现可以了

 


不要使用brew安装,太麻烦了node安装好后npm又可能失效

 

最好还是通过官网http://nodejs.cn/download/

方便快捷

更建议使用nvm安装:

https://github.com/nvm-sh/nvm#installing-and-updating

这样就可以了

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
检查:
command -v nvm

使用例子:

nvm install 12.4.0 或 nvm install 11.15.0

你可能感兴趣的:(前端)