mac 安装yarn

使用mac 脚本安装

curl -o- -L https://yarnpkg.com/install.sh | bash  

使用homebrew安装

brew install yarn 

使用npm安装

npm install -g yarn 

---------------------

三种方法,一种失败就直接换其他的。

---------------------

安装成功,查看yarn版本,

yarn --version

或者


yarn -V

此时报错:

zsh: command not found: yarn

 

原因是没有配置path,此时不要慌

1. touch ~/.bash_profile   //touch的意思是没有就创建;.bash_profile这是系统临时的环境变量, 
   
2.  sudo open -e ~/.bash_profile

此时如果能打开一个文本文件就直接复制上面安装成功后出现的那个配置地址,(如果此时报错则去文末查看相关引用连接

我的是

export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"

此时再执行

source ~/.bash_profile

再次查看版本

v1.22.5

----------------------

 

问题解决思路来自 ALLen、LAS 

 

 点个赞吧~

原文地址:https://www.cnblogs.com/qiangqiangpeng/p/14201801.html