mac 使用brew卸载安装node
卸載
1. 查看當前安裝的node版本:
node -v
2. 卸載node:
brew uninstall node@版本號 --force
比如安裝的是12.18.1,使用brew uninstall node@12 --force。
還有另外兩種現(xiàn)在不能用的方法:
- 使用brew uninstall node,會報錯:Error: No such keg: /usr/local/Cellar/node
- brew uninstall node --force不起作用。
3. 刪除配置的環(huán)境變量
touch ~/.bash_profile 顯示隱藏的.bash_profile文件
open ~/.bash_profile 打開.bash_profile文件,并刪除里邊的有關node的配置并保存
source ~/.bash_profile 執(zhí)行.bash_profile文件使生效。
運行第2步之后,運行node -v 發(fā)現(xiàn)會報:
-bash: /usr/local/opt/node@12/bin/node: No such file or directory這種情況就是配置的環(huán)境變量沒有刪除。
安裝
1. 查看本機可安裝的node版本:
brew search node
可以安裝的版本有10、12。后邊打勾的是已經(jīng)安裝的。
2.安裝node
brew install node@10
3. 鏈接(很重要,否則node不能使用)
brew link node@10
4. 鏈接之后會報兩個建議希望你執(zhí)行兩個命令,按照執(zhí)行就好了。
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。
升級后,檢查是否安裝成功,沒有的話,重新安裝。
- 卸載過程中出錯,導致有文件沖突。 解決方案:診斷有哪些沖突文件,刪除。
刪除完成,檢查是否安裝成功,沒有的話,重新安裝。
總結(jié)
以上是生活随笔為你收集整理的mac 使用brew卸载安装node的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 摩尔庄园官服和渠道服的区别
- 下一篇: via怎么安装脚本