当前位置:   article > 正文

mac安装yarn报错:Error: command failed: yarn_error error: command failed: yarn error: command f

error error: command failed: yarn error: command failed: yarn at childproces

安装yarn的时候报错

创建vue项目报错如下

ERROR  Error: command failed: yarn
Error: command failed: yarn
    at ChildProcess.<anonymous> (/usr/local/lib/node_modules/@vue/cli/lib/util/executeCommand.js:138:16)
    at ChildProcess.emit (events.js:400:28)
    at maybeClose (internal/child_process.js:1058:16)
    at Socket.<anonymous> (internal/child_process.js:443:11)
    at Socket.emit (events.js:400:28)
    at Pipe.<anonymous> (net.js:686:12)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

执行命令:

npm install -g yarn
  • 1

出现如下错误

$ npm install -g yarn
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/lishanshan/.npm/_logs/2023-06-04T14_07_51_925Z-debug.log
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23

原因是此用户没有安装权限
使用sudo对用户提权,这与linux很相似

$ sudo npm install -g yarn
  • 1

然后输入该系统账号密码

> yarn@1.22.19 preinstall /usr/local/lib/node_modules/yarn
> :; (node ./preinstall.js > /dev/null 2>&1 || true)

/usr/local/bin/yarnpkg -> /usr/local/lib/node_modules/yarn/bin/yarn.js
/usr/local/bin/yarn -> /usr/local/lib/node_modules/yarn/bin/yarn.js
+ yarn@1.22.19
added 1 package in 3.299s
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
yarn -v
  • 1

相应版本即安装成功~

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/531121
推荐阅读
相关标签
  

闽ICP备14008679号