sharp 安装失败

NodeBB git:(v1.10.x) npm i sharp

> [email protected] install /Users/wdxmm/workspace/NodeBB/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

sharp: Downloading https://npm.taobao.org/mirrors/sharp-libvips/v8.8.1/libvips-8.10.6-darwin-x64.tar.br
sharp: Prebuilt libvips 8.10.6 binaries are not yet available for darwin-x64
sharp: Attempting to build from source via node-gyp but this may fail due to the above error
sharp: Please see https://sharp.pixelplumbing.com/install for required dependencies
  CC(target) Release/obj.target/nothing/../node-addon-api/nothing.o
  LIBTOOL-STATIC Release/nothing.a
  TOUCH Release/obj.target/libvips-cpp.stamp
  CXX(target) Release/obj.target/sharp/src/common.o
../src/common.cc:24:10: fatal error: 'vips/vips8' file not found
#include 
         ^~~~~~~~~~~~
1 error generated.
make: *** [Release/obj.target/sharp/src/common.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
gyp ERR! System Darwin 19.3.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/wdxmm/workspace/NodeBB/node_modules/sharp
gyp ERR! node -v v14.16.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok 
npm WARN [email protected] requires a peer of ajv@^6.9.1 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of eslint@^4.9.0 but none is installed. You must install peer dependencies yourself.

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!     /Users/wdxmm/.npm/_logs/2021-04-12T07_56_39_775Z-debug.log

我真的是试了巨多方法
一、配置download代理,使用淘宝镜像,不行,download的地址404

npm config set sharp_binary_host "[https://npm.taobao.org/mirrors/sharp](https://npm.taobao.org/mirrors/sharp)" 
npm config set sharp_libvips_binary_host "[https://npm.taobao.org/mirrors/sharp-libvips](https://npm.taobao.org/mirrors/sharp-libvips)" 
npm install sharp

二、手动下载sharp-libvips到.npm/.libvips
下载log信息对应的sharp-libvips版本到相应的目录中去,还是不能下载

三、最终,我终于反应过来,可能是package.json对应的sharp版本过低,导致对应的sharp-libvips也无法下载,果然,修改sharp版本后一切都正常了

image.png

最终我发现,我一开始下载的nodeBB版本就太旧了,果然一开始就努力错了

你可能感兴趣的:(sharp 安装失败)