版权声明:转载请注明一下来自于Lateautunm,感谢赏识。 https://blog.csdn.net/weixin_43116910/article/details/86037823
最近在使用node install
安装项目依赖时发现了这个问题,当执行用户是root
的时候就会遇到这类问题,提示gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/10.15.0"
,这个问题可参考issue
具体的原因是因为避免以root 的身份去执行lifecycle 命令时可能造成的安全问题,要避开该问题,只要覆盖default中的初始值即可,比如用cli
参数或者npm config set unsafe-perm=true
。
如果站在项目角度避开该问题,可以采取的措施是在项目中创建.npmrc
来覆盖default
的配置:
// .npmrc
unsafe-perm = true
但可能需要明确带来的风险。