EACCES: permission denied

EACCES: permission denied, mkdir ‘/usr/local/lib/node_modules/nw/nwjs’

最近安装 nwjs 和 electron 都出现了权限问题,开了 sudo 也是不好使,问题如下:

nihao-mac:~ nihao sudo npm i nw -g
Password:
/usr/local/bin/nw -> /usr/local/lib/node_modules/nw/bin/nw

> nw@0.31.5 postinstall /usr/local/lib/node_modules/nw
> node scripts/install.js

EACCES: permission denied, mkdir '/usr/local/lib/node_modules/nw/nwjs'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nw@0.31.5 postinstall: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the nw@0.31.5 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/nihao/.npm/_logs/2018-07-11T02_55_49_361Z-debug.log

查找了N多方法,最后终于解决,命令如下

sudo npm i nw -g –unsafe-perm=true –allow-root

注意 –unsafe-perms 参数。

随手记下,有不当之处请留言!如果对小伙伴们有帮助的话,点赞啊,谢谢!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值