安装包的时候提示如下:gyp WARN EACCES user "nobody" does not have permission to access the dev dir
或者gyp WARN EACCES user "root" does not have permission to access the dev dir
解决方法:npm install xxxx -g --unsafe-perm
有时候可以先执行:npm cache clean --force
参考:https://javascript.net.cn/article?id=657
Having the same issue on npm 5.4.2. Initially I tried npm cache clear --force but it did not resolve my issue. Removing package-lock.json didn't either.
Removing both node_modules and package-lock.json worked:
rm -rf node_modules/
rm package-lock.json
# Install and add the package