第一句子网 - 唯美句子、句子迷、好句子大全
第一句子网 > mac 使用brew卸载安装node

mac 使用brew卸载安装node

时间:2019-12-22 12:46:58

相关推荐

mac 使用brew卸载安装node

卸载

1. 查看当前安装的node版本:

node -v

2. 卸载node:

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不起作用。

3. 删除配置的环境变量

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

这种情况就是配置的环境变量没有删除。

安装

1. 查看本机可安装的node版本:

brew search node

可以安装的版本有10、12。后边打勾的是已经安装的。

2.安装node

brew install node@10

3. 链接(很重要,否则node不能使用)

brew link node@10

4. 链接之后会报两个建议希望你执行两个命令,按照执行就好了。

brew link node@10 --force

echo ‘export PATH="/usr/local/opt/node@10/bin:$PATH"’ >> /Users/shenqinci/.bash_profile

5.检查是否安装成功

node -v

如果成功,会显示你安装的版本号。

有时会报错误:

-bash: node: command not found

一般有两个原因:

mac刚升级了10.15.0以上版本,解决方案:升级brew。

brew update

升级后,检查是否安装成功,没有的话,重新安装。

卸载过程中出错,导致有文件冲突。 解决方案:诊断有哪些冲突文件,删除。

brew doctor

删除完成,检查是否安装成功,没有的话,重新安装。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。