安装锐器时出了点问题

时间:2019-09-11 06:51:25

标签: node.js linux centos7 sharp nodebb

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

总是sharp是,我讨厌。

我不知道为什么不能获得许可,我是root角色。 我自己尝试过mkdir,但是npm删除了它,然后告诉我,“权限被拒绝”,对不起,我吗????

我尝试将sharpnpm install sharp --ignore-scripts一起安装,并自己安装依赖项。通过这种方式,我可以运行nodebb服务器,但是当我尝试从浏览器上传图像并对其进行锐化时,nodebb出现了最后一个错误

这是安装时出现的错误消息:

[root@bbs NodeBB]# npm install sharp
> sharp@0.23.0 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! sharp@0.23.0 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 sharp@0.23.0 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

4 个答案:

答案 0 :(得分:1)

我解决了,但是我不知道为什么

通过以下命令:sudo chown -R $(whoami) node_modules/

我总是使用root,功能强大

答案 1 :(得分:0)

如果您和我住在同一国家,那么最大的原因就是GFW。 我曾经遇到过与您相同的问题。 您可以尝试为此修改npm镜像源。

答案 2 :(得分:0)

将Node从v10升级到v12后,我遇到了此错误。我的项目仍然使用v10时安装的node_modules。因此,我想它们与另一个Node版本的安装方式有所不同。以下内容对我有帮助:

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

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

答案 3 :(得分: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中将所需的清晰版本更改为0.22.1
    {"dependencies: {
    ...
           "sharp": "0.24.0",
    ...
    }
  • 现在,开始设置过程
    ./nodebb setup

现在一切正常。