node -v
brew uninstall node@版本号 --force
比如安装的是12.18.1,使用brew uninstall node@12 --force。
还有另外两种现在不能用的方法:
使用brew uninstall node,会报错:Error: No such keg: /usr/local/Cellar/nodebrew uninstall node --force不起作用。touch ~/.bash_profile 显示隐藏的.bash_profile文件 open ~/.bash_profile 打开.bash_profile文件,并删除里边的有关node的配置并保存 source ~/.bash_profile 执行.bash_profile文件使生效。
运行第2步之后,运行node -v 发现会报:
-bash: /usr/local/opt/node@12/bin/node: No such file or directory这种情况就是配置的环境变量没有删除。
brew search node
可以安装的版本有10、12。后边打勾的是已经安装的。
brew install node@10
brew link node@10
brew link node@10 --force echo ‘export PATH="/usr/local/opt/node@10/bin:$PATH"’ >> /Users/shenqinci/.bash_profile
node -v
如果成功,会显示你安装的版本号。
一般有两个原因:
mac刚升级了10.15.0以上版本,解决方案:升级brew。 brew update升级后,检查是否安装成功,没有的话,重新安装。
卸载过程中出错,导致有文件冲突。 解决方案:诊断有哪些冲突文件,删除。 brew doctor删除完成,检查是否安装成功,没有的话,重新安装。