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

> [email protected] 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! [email protected] postinstall: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] 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 参数。

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

你可能感兴趣的:(随笔)