无法安装 gatsby-cil :npm ERR! sh:1:node-gyp-build:权限被拒绝
我尝试使用 npm 在 WLS2 上安装 gatsby-cil 但失败了。
这是错误消息,
root@LAPTOP-7EEFPLOM:~# npm install -g gatsby-cli
npm WARN deprecated [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm ERR! code 127
npm ERR! path /root/.nvm/versions/node/v16.14.0/lib/node_modules/gatsby-cli/node_modules/lmdb
npm ERR! command failed
npm ERR! command sh -c node-gyp-build
npm ERR! sh: 1: node-gyp-build: Permission denied
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-03-14T01_49_08_533Z-debug-0.log
我一开始以为是 WSL 造成的,然后我尝试在云服务器上执行相同的操作并得到相同的结果。
我也尝试了网上找到的解决方案:
npm config set user 0
npm config set unsafe-perm true
但还是出现同样的错误
I tried to install gatsby-cil on WLS2 with npm and failed.
here is the error message
root@LAPTOP-7EEFPLOM:~# npm install -g gatsby-cli
npm WARN deprecated [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm ERR! code 127
npm ERR! path /root/.nvm/versions/node/v16.14.0/lib/node_modules/gatsby-cli/node_modules/lmdb
npm ERR! command failed
npm ERR! command sh -c node-gyp-build
npm ERR! sh: 1: node-gyp-build: Permission denied
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-03-14T01_49_08_533Z-debug-0.log
I thought it was WSL that is to blame at first, then I tried to do the same thing on a cloud server and got the same result.
I also tried a solution found on the Internet:
npm config set user 0
npm config set unsafe-perm true
but still got the same error
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试:
您似乎没有足够的权限(在两种环境中)来安装全局包,因此更改
~/
权限文件夹可能会解决您的问题。由于这不是与 Gatsby 相关的问题(来自其依赖项),您还可以尝试使用 sudo 权限单独安装它们。在这种情况下:
那么您应该能够再次安装
gatsby-cli
,这应该跳过node-gyp
包。Try:
It seems that you don't have enough permission (in both environments) to install global packages so changing the
~/
permission folder may fix your issue.Since it's not a Gatsby-related issue (it's from its dependencies), you can also try installing them separately using
sudo
permissions. In this case:Then you should be able to install
gatsby-cli
again, which should skip thenode-gyp
package.