You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

安装Gatsby Starter时sharp依赖安装失败,求解决方案

Fixing Sharp Installation Error When Setting Up Gatsby Starter

Hey there, let's get this sorted out! The error you're hitting happens because your Mac system is missing the libffi library—something the sharp package (a dependency of favicons) needs to build successfully. Here's a step-by-step fix:

  • First, update Homebrew to make sure you're working with the latest package versions:

    brew update
    
  • Install the missing libffi library using Homebrew:

    brew install libffi
    
  • Next, tell pkg-config where to find the libffi configuration file by setting the environment variable:

    export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"
    

    Note: If you use zsh, add this line to your ~/.zshrc file so it persists across terminal sessions. For bash, add it to ~/.bash_profile.

  • Clean up your existing installation files to avoid leftover conflicts:

    rm -rf node_modules
    rm package-lock.json
    
  • Finally, reinstall your project dependencies from scratch:

    npm install
    

If you still run into issues after these steps, try reinstalling sharp directly with force to ensure it builds correctly:

npm install sharp --force

To give a bit of context: The error log calls out "Package 'libffi', required by 'gobject-2.0', not found"—this means the sharp build process couldn't locate the libffi library, which is a critical dependency for gobject-2.0. By installing libffi and updating the pkg-config path, we're giving the build tool exactly what it needs to compile sharp successfully.

内容的提问来源于stack exchange,提问作者Wing Cheung Kwok

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 08:09:24