无法安装 gatsby-cil :npm ERR! sh:1:node-gyp-build:权限被拒绝

发布于 2025-01-13 18:39:37 字数 983 浏览 1 评论 0原文

我尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光暖心i 2025-01-20 18:39:37

尝试:

sudo chown -R $(whoami) ~/

您似乎没有足够的权限(在两种环境中)来安装全局包,因此更改 ~/ 权限文件夹可能会解决您的问题。

由于这不是与 Gatsby 相关的问题(来自其依赖项),您还可以尝试使用 sudo 权限单独安装它们。在这种情况下:

sudo npm install -g node-gyp node-pre-gyp node-gyp-build

那么您应该能够再次安装 gatsby-cli,这应该跳过
node-gyp 包。

Try:

sudo chown -R $(whoami) ~/

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:

sudo npm install -g node-gyp node-pre-gyp node-gyp-build

Then you should be able to install gatsby-cli again, which should skip the
node-gyp package.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文