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

2024-07-04   阅读:184   类型:前端   分类:Vue    标签: Vue macOS

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
【腾讯云】2核2G云服务器新老同享 99元/年,续费同价,云服务器3年机/5年机限时抢购,低至 2.5折

‘简忆博客’微信公众号 扫码关注‘简忆博客’微信公众号,获取最新文章动态
转载:请说明文章出处“来源简忆博客”。http://tpxhm.com/fdetail/1092.html

×
觉得文章有用就打赏一下文章作者
微信扫一扫打赏 微信扫一扫打赏
支付宝扫一扫打赏 支付宝扫一扫打赏

文章评论(0)

登录
简忆博客壁纸一
简忆博客壁纸二
简忆博客壁纸三
简忆博客壁纸四
简忆博客壁纸五
简忆博客壁纸六
简忆博客壁纸七
简忆博客壁纸八
头像

简忆博客
勤于学习,乐于分享

置顶推荐

打赏本站

如果你觉得本站很棒,可以通过扫码支付打赏哦!
微信扫码:你说多少就多少~
微信扫码
支付宝扫码:你说多少就多少~
支付宝扫码
×