第一句子网 - 唯美句子、句子迷、好句子大全
第一句子网 > macos -bash: yarn: command not found/-bash: cnpm: command not found

macos -bash: yarn: command not found/-bash: cnpm: command not found

时间:2023-06-08 12:37:35

相关推荐

macos -bash: yarn: command not found/-bash: cnpm: command not found

博客主要更新地址:?/niceyoo

-bash: cnpm: command not found

-bash: yarn: command not found

-bash: xxxx: command not found

如上yarn/cnpm皆通用,前提是安装成功后报这个错误哈!

Error: EACCES: permission denied, mkdir错误的同学请移步这篇文章 ?/niceyoo/p/11703560.html

不同于Windows,我们使用了sudo npm install -g yarn安装了yarn,但是在终端打印版本或者是直接使用yarn却报如下错误信息:

-bash: yarn: command not found

其中一种原因:没有配置类似于Windows里的环境变量。

在终端输入:

open -e ~/.bash_profile

上方指令方式将通过记事本直接编辑的方式,或者是采用控制台的vim指令

vim ~/.bash_profile

如果采用vim的方式修改后记得执行:wq保存退出。

我们以open指令为例,在终端执行如下指令:

1、touch ~/.bash_profile

可跳过,touch的意思是没有就创建,.bash_profile为系统临时的环境变量

2、open -e ~/.bash_profile

open指令打开这个文件,如果提示没有权限 请在前面加上sudo,示例:sudo open -e ~/.bash_profile

3、找到安装的yarn目录

还记得安装yarn的目录吗?如果忘记了再执行安装一边呗,如下图所示(图片为网上的非本人打码):

4、在发开的bash_profile文件中输入export PATH=$PATH:/usr/local/node_global/bin

注意:请将/usr/local/node_global替换为你的 yarn 存在的目录

5、source ~/.bash_profile

source 表示重新执行、刷新的意思

6、yarn -v

我创建了一个java相关的公众号,用来记录自己的学习之路,感兴趣的小伙伴可以关注一下微信公众号哈:niceyoo

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。