由于尖锐原因无法安装gatsby启动器

时间:2019-09-28 18:42:21

标签: gatsby sharp

当我想安装盖茨比启动器时,在终端中出现了这些错误。 有人知道如何解决吗?

[4/4] ?  Building fresh packages...
[6/13] ⠁ sharp
[-/13] ⠁ waiting...
[-/13] ⠁ waiting...
[12/13] ⠁ sharp
error /Users/anykey/Documents/GitHub/a1000/node_modules/favicons/node_modules/sharp: Command failed.
Exit code: 1
Command: (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
Arguments: 
Directory: /Users/anykey/Documents/GitHub/a1000/node_modules/favicons/node_modules/sharp
Output:
info sharp Detected globally-installed libvips v8.8.3
info sharp Building from source via node-gyp
gyp info it worked if it ends with ok
gyp info using node-gyp@5.0.3
gyp info using node@10.16.3 | darwin | x64
gyp info find Python using Python version 2.7.10 found at "/usr/bin/python"
gyp info spawn /usr/bin/python
gyp info spawn args [ '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/anykey/Documents/GitHub/a1000/node_modules/favicons/node_modules/sharp/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/anykey/Library/Caches/node-gyp/10.16.3/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/anykey/Library/Caches/node-gyp/10.16.3',
gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/anykey/Library/Caches/node-gyp/10.16.3/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/anykey/Documents/GitHub/a1000/node_modules/favicons/node_modules/sharp',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
Package 'libffi', required by 'gobject-2.0', not found
gyp: Call to 'PKG_CONFIG_PATH="/usr/lib/pkgconfig:/usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig/10.14:/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
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:344:16)
gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Darwin 18.5.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/anykey/Documents/GitHub/a1000/node_modules/favicons/node_modules/sharp
gyp ERR! node -v v10.16.3

5 个答案:

答案 0 :(得分:1)

我有类似的问题。就我而言,错误日志中的内容如下所示

error /<path to the project>/node_modules/sharp: Command failed.
Exit code: 1
Command: (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
Arguments: 
Directory: /<path to the project>/node_modules/sharp
Output:
info sharp Using cached /home/username/.npm/_libvips/libvips-8.8.1-linux-x64.tar.gz
ERR! sharp Please delete /home/username/.npm/_libvips/libvips-8.8.1-linux-x64.tar.gz as it is not a valid tarball

正如您在最后几行中所见,sharp使用的是libvips的缓存版本,删除缓存的libvips tarball对我来说解决了这个问题。


但是对于OP来说,他/她似乎已根据错误日志中的以下行全局安装了libvips

info sharp Detected globally-installed libvips v8.8.3
npm -g uninstall libvips

可能会解决他/她的问题。

答案 1 :(得分:0)

问题可能是由于节点v12.x并使用npm而不是yarn导致的。

解决此问题的步骤。

1)使用nvm(管理不同的节点版本)将您的节点版本降级到10.x(v10.16.0为我解决了问题)。用于nvm的命令是:

 a) "nvm install 10.16.0" (to install node version).

 b) "nvm use 10.16.0" (to switch between different node versions).

2)使用yarn通过以下命令安装依赖项:

  yarn

如果已经使用过npm,则删除node_modules和package.lock.json,然后尝试上述步骤。

答案 2 :(得分:0)

由于我安装了多个节点版本,因此降级为上一个版本

首先,我检查了可用和正在使用的节点版本

nvm ls
         v12.18.4
  ->     v14.15.0
         v14.15.1

然后降级到以前的节点版本

nvm use v12.18.4

所以我的Gatsby产品文件夹中的纱线安装再次正常

cd my-gatsby-folder
yarn install

您可以决定使用旧节点版本作为默认版本

nvm alias default 12

答案 3 :(得分:0)

我用 Homebrew 安装了 vips。卸载它解决了我的问题,运行:

brew uninstall vips
然后:
yarn install(或npm install

答案 4 :(得分:-1)

我在我的 gatsby 项目中解决了这个问题,我使用 yarn install 而不是 npm install