首先查找yarn global的安装目录
yarn global dir
找到yarn global安装路径后,比如路径如下:
/Users/username/.config/yarn/global/node_modules/.bin
修改~/.bash_profile
使用Xcode打开 你也可以用别的打开 比如 vim ~/.bash_profile或
open -a xcode ~/.bash_profile
加一行
export PATH="$PATH:/Users/username/.config/yarn/global/node_modules/.bin"
加完再命令行执行(让命令生效)
source ~/.bash_profile
之后我们输入vue --help,发现可以使用了。
mac系统,在 ~/.bash_profile 中配置环境变量, 可是每次重启终端后配置的不生效.需要重新执行 : $source ~/.bash_profile
发现zsh加载的是 ~/.zshrc文件,而 ‘.zshrc’ 文件中并没有定义任务环境变量。
解决办法
open -a xcode ~/.zshrc
在~/.zshrc文件最后,增加一行:
source ~/.bash_profile