sharp error: Package OpenEXR was not found in the pkg-config search path

sharp error: Package OpenEXR was not found in the pkg-config search path

我在 Mac 上的 gatsby js 目录上执行了 npm install

已显示此错误日志。

npm ERR! code 1
npm ERR! path /Users/<username>/<path>/node_modules/sharp
npm ERR! command failed
npm ERR! command sh -c (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
npm ERR! sharp: Detected globally-installed libvips v8.11.2
npm ERR! sharp: Building from source via node-gyp
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@7.1.2
npm ERR! gyp info using node@15.14.0 | darwin | x64
npm ERR! gyp info find Python using Python version 3.7.0 found at "/Users/<username>/.pyenv/versions/3.7.0/bin/python3"
npm ERR! gyp info spawn /Users/<username>/.pyenv/versions/3.7.0/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/Users/<username>/.nodebrew/node/v15.14.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/<username>/<path>/blog/node_modules/sharp/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/<username>/.nodebrew/node/v15.14.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/<username>/Library/Caches/node-gyp/15.14.0/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/Users/<username>/Library/Caches/node-gyp/15.14.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/Users/<username>/.nodebrew/node/v15.14.0/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/<username>/Library/Caches/node-gyp/15.14.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/<username>/<path>/blog/node_modules/sharp',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! Package OpenEXR was not found in the pkg-config search path.
npm ERR! Perhaps you should add the directory containing `OpenEXR.pc'
npm ERR! to the PKG_CONFIG_PATH environment variable
npm ERR! Package 'OpenEXR', required by 'vips', not found
npm ERR! gyp: Call to 'PKG_CONFIG_PATH="/usr/lib/pkgconfig:/usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig/11::/usr/local/opt/libffi/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig" pkg-config --cflags-only-I vips-cpp vips glib-2.0 | sed s\/-I//g' returned exit status 0 while in binding.gyp. while trying to load binding.gyp
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onCpExit (/Users/<username>/.nodebrew/node/v15.14.0/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:369:20)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Darwin 20.5.0
npm ERR! gyp ERR! command "/Users/<username>/.nodebrew/node/v15.14.0/bin/node" "/Users/<username>/.nodebrew/node/v15.14.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /Users/<username>/<path>/blog/node_modules/sharp
npm ERR! gyp ERR! node -v v15.14.0
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok

我试过 brew reinstall vips 但错误没有得到解决。有人知道这是什么吗?

我安装了 OpenEXR。我重新解决了这个错误。

https://github.com/AcademySoftwareFoundation/openexr/blob/master/INSTALL.md

不知道为什么 ilmbase 和 OpenEXR 有冲突的链接。

这对我有用。

brew install openexr
brew unlink ilmbase
brew link openexr
brew install imath
brew link imath