无法安装夏普

flo*_*olu 2 node.js npm sharp

运行时sudo npm i sharp --save出现以下错误:

> sharp@0.21.3 install /home/server/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

info sharp Using cached /home/ronny/.npm/_libvips/libvips-8.7.0-linux-x64.tar.gz
ERR! sharp EACCES: permission denied, mkdir '/home/server/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/server/node_modules/sharp/build'
gyp ERR! System Linux 4.18.0-13-generic
gyp ERR! command "/usr/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/server/node_modules/sharp
gyp ERR! node -v v8.11.4
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm WARN server@1.0.0 No description
npm WARN server@1.0.0 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sharp@0.21.3 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.21.3 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!     /home/ronny/.npm/_logs/2019-01-28T20_33_46_476Z-debug.log
Run Code Online (Sandbox Code Playgroud)

我在另一台计算机上运行了相同的项目,并且安装正常进行。但是在我的另一台机器上(都运行Linux Ubuntu),我遇到了上面的错误。

我找不到此错误的任何解决方案。这就是为什么我在这里寻求帮助。

小智 20

这实际上对我有帮助,使用节点 14.20.1

npm install sharp --ignore-scripts
Run Code Online (Sandbox Code Playgroud)


Jim*_*Jim 15

最简单的方法是:

brew uninstall vips
Run Code Online (Sandbox Code Playgroud)

进而:

npm install
Run Code Online (Sandbox Code Playgroud)

  • 我们能否解释一下为什么会这样?为何获得赞成票? (2认同)

Usa*_*hir 11

这对我有用。 npm install --unsafe-perm

请参考以下讨论 https://github.com/lovell/sharp/issues/1627#issuecomment-477109851


crg*_*g63 11

对于苹果 M1 brew install vips那么npm install --unsafe-perm

如果它没有解决您的问题,请在这个类似的问题中找到更多内容

  • xcode-选择--安装
  • 酿造安装海湾合作委员会
  • 重新安装vips
  • 酿造信息 VIP
  • 尼普我


tej*_*s n 8

npm install --arch=x64 --platform=linux sharp为我工作

摘自: https: //github.com/lovell/sharp/issues/2128#issuecomment-600232917

我使用的是M1 mac


小智 7

Node v13.14.0+的问题,问题就解决了

npm install sharp@0.23.2 
Run Code Online (Sandbox Code Playgroud)

如果您使用的是 Sharp 0.22.1,则应将 Node 版本降级至 >=10.0.0