安装sharp时出现一些问题

问题描述 投票:0回答:4

当我尝试安装nodebb并使用命令“nodebb setup”初始化它时,并且 然后自动安装第三方包,总是报错,错误信息如下。

是的,总是这样

sharp
,我讨厌那样。

我不知道为什么没有权限,我是 root 角色。 我尝试自己 mkdir 但 npm 将其删除,然后告诉我,“权限被拒绝”,对不起??????

我尝试用

sharp
安装
npm install sharp --ignore-scripts
并自行安装依赖。通过这种方式,我可以运行nodebb服务器,但是当我尝试从浏览器上传图像并锐化它时,nodebb出现如下错误

这是安装时的一些错误消息:

[root@bbs NodeBB]# npm install sharp
> [email protected] install /home/bbs/NodeBB/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
info sharp Using cached /root/.npm/_libvips/libvips-8.8.1-linux-x64.tar.gz
ERR! sharp EACCES: permission denied, mkdir '/home/bbs/NodeBB/node_modules/sharp/vendor'
info sharp Attempting to build from source via node-gyp but this may fail due to the above error
info sharp Please see https://sharp.pixelplumbing.com/page/install for required dependencies
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/home/bbs/NodeBB/node_modules/sharp/build'
gyp ERR! System Linux 3.10.0-957.el7.x86_64
gyp ERR! command "/usr/share/node-v12.9.1-linux-x64/bin/node" "/usr/share/node-v12.9.1-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/bbs/NodeBB/node_modules/sharp
gyp ERR! node -v v12.9.1
gyp ERR! node-gyp -v v5.0.3
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install 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!     /root/.npm/_logs/2019-09-11T06_23_30_748Z-debug.log

这是上传图片时的一些错误消息:

Something went wrong installing the "sharp" module

Cannot find module '../build/Release/sharp.node'
Require stack:
- /home/bbs/NodeBB/node_modules/sharp/lib/constructor.js
- /home/bbs/NodeBB/node_modules/sharp/lib/index.js
- /home/bbs/NodeBB/src/file.js
- /home/bbs/NodeBB/require-main.js
- /home/bbs/NodeBB/app.js

- Remove the "node_modules/sharp" directory, run "npm install" and look for errors
- Consult the installation documentation at https://sharp.pixelplumbing.com/en/stable/install/
- Search for this error at https://github.com/lovell/sharp/issues
node.js linux centos7 sharp nodebb
4个回答
4
投票

我解决了,但不知道怎么解决

我使用了这个命令:

sudo chown -R $(whoami) node_modules/

请记住,除了系统管理之外,您不应该使用 root 进行任何其他操作。


1
投票

将 Node 从 v10 升级到 v12 后,我遇到了这个错误。我的项目仍然使用 v10 时安装的

node_modules
。所以我猜他们的安装方式与另一个 Node 版本不同。以下内容对我有帮助:

rm -rf node_modules
rm package-lock.json
npm install

现在每个已安装的节点模块在安装过程中都使用了最新的 Node 版本。


0
投票

如果你和我住在同一个国家,那么最大的原因就是GFW。 我曾经遇到过和你一样的问题。 你可以尝试修改npm镜像源来解决这个问题


0
投票

我在尝试安装 NodeBB 1.12.1 时遇到了与 sharp 安装相同的错误。问题似乎出在过时的锐利版本上。 我解决了它,更正了 package.json 中所需的锐利版本。 解决办法如下:

  • 克隆存储库
    git clone https://github.com/NodeBB/NodeBB.git nodebb
  • 结帐至所需分行
    git checkout v1.12.1
  • 转到 ~/nodebb/install 并在 package.json 中将所需的 Sharp 版本更改为 0.22.1
    {"dependencies: {
    ...
           "sharp": "0.24.0",
    ...
    }
  • 现在,开始设置过程
    ./nodebb setup

现在一切都应该正常了。

© www.soinside.com 2019 - 2024. All rights reserved.