安装

  • 直接安装
curl -o- -L https://yarnpkg.com/install.sh | bash
  • npm 方式
npm install -g yarn

错误及解决

  • 错误
➜  ~ yarn --version
zsh: command not found: yarn
  • 原因 没有在环境变量中配置yarn
  • 解决
1. touch ~/.bash_profile  // 可跳过 //touch的意思是没有就创建  .bash_profile 系统临时的环境变量
   
2.  sudo open -e ~/.bash_profile  // 打开
  1. 要先找到yarn的安装路径
yarn config get prefix

Mac 安装yarn_重启

2. 修改.bash_profile文件,配置path变量。对于zsh用户,请确保将此行添加到〜/ .zshrc

export PATH="$PATH:/***/bin"  // ***是你安装yarn的路径
  1. 运行
source ~/.bash_profile   // source表示重新执行、刷新的意思
yarn --vesion

Mac 安装yarn_环境变量_02

  • 错误
prompt_status:5: command not found: wc
  • 解决 重启(关闭当前命令行窗口即可 否则执行所有命令都会出现prompt_status:5: command not found: wc )