MAC bookPro出現(xiàn)zsh: command not found: xxx解決方法:
把 bash shell 中.bash_profile 全部環(huán)境變量加入zsh shell里就好
step1:
Term執(zhí)行
open .zshrc
step2:
在彈出的編輯器最下面
加入
source ~/.bash_profile
或者
source .bash_profile
看哪個(gè)奏效,這一步就在zshrc執(zhí)行時(shí)將?.bash_profile 全部環(huán)境變量加入zsh shell了
保存
step3:
terminal執(zhí)行
source .zshrc? ? ? ? ? ? ? 更新配置
如果到此你已經(jīng)解決了問(wèn)題,那恭喜你了岭皂,可題主我就沒(méi)這么幸運(yùn),我在terminal執(zhí)行source .zshrc時(shí)報(bào)找不到bash_profile钉汗,坑爹的有些mac就是沒(méi)有bash_profile這個(gè)文件,需要手動(dòng)新建鲤屡,如果你也是這樣請(qǐng)繼續(xù)跟我操作
step:1
terminal執(zhí)行
touch .bash_profile? ? ? ? ?創(chuàng)建.bash_profile?
這時(shí)候就有了bash_profile這個(gè)文件损痰,當(dāng)然是沒(méi)有內(nèi)容的空文件,這里又需要你寫(xiě)入path执俩,我接下來(lái)是這么操作的
step:2
創(chuàng)建global安裝任務(wù)的目錄
mkdir ~/.npm-global
step:3
配置npm全局下載時(shí),下載到新的地址目錄
npm config set prefix '~/.npm-global'
至此你再npm i xxx -g就會(huì)存儲(chǔ)到npm-global的地址下了
step:4
open?.bash_profile
在彈出的編輯器中增加配置
export PATH=~/.npm-global/bin:${PATH}
保存
step:5
terminal執(zhí)行
source .bash_profile? ? 更新配置
至此解決問(wèn)題