关于MacBook电脑安装yarn报错errno -13 npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/yarn解决办法
侧边栏壁纸
  • 累计撰写 635 篇文章
  • 累计收到 0 条评论

关于MacBook电脑安装yarn报错errno -13 npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/yarn解决办法

加速器之家
2024-08-22 / 0 评论 / 5 阅读 / 正在检测是否收录...

yarn介绍:

Yarn是facebook发布的一款取代npm的包管理工具

yarn特点:

速度超快:Yarn 缓存了每个下载过的包,所以再次使用时无需重复下载。 同时利用并行下载以最大化资源利用率,因此安装速度更快。

超级安全:在执行代码之前,Yarn 会通过算法校验每个安装包的完整性。

超级可靠:使用详细、简洁的锁文件格式和明确的安装算法,Yarn 能够保证在不同系统上无差异的工作。

然而在Mac下安装会遇到问题:报没权限安装问题,如下所示:

npm install -g yarn

npm notice

npm notice New major version of npm available! 8.19.4 -> 10.8.1

npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.8.1

npm notice Run npm install -g npm@10.8.1 to update!

npm notice

npm ERR! code EACCES

npm ERR! syscall mkdir

npm ERR! path /usr/local/lib/node_modules/yarn

npm ERR! errno -13

npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/yarn'

npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/yarn'] {

npm ERR! errno: -13,

npm ERR! code: 'EACCES',

npm ERR! syscall: 'mkdir',

npm ERR! path: '/usr/local/lib/node_modules/yarn'

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! /Applications/MxSrvs/cache/nodejs/_logs/2024-07-04T13_28_15_750Z-debug-0.log

出现这个问题,我们可以采用以下命令执行,也就是加速sudo

sudo npm install -g yarn
0

评论

博主关闭了当前页面的评论