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

使用Metaplex搭建Solana Candy Machine时执行yarn install遇node-gyp错误的解决咨询

Fixing node-gyp/node-pre-gyp Errors When Installing Metaplex CLI for Solana Candy Machine

Yep, this issue is definitely tied to node-pre-gyp and the canvas package's system-level dependencies. Here's what's going on:
The canvas package (a dependency of Metaplex CLI) relies on node-pre-gyp to fetch precompiled binary files for your system. If that download fails (due to network issues, version mismatches, or missing system tools), it falls back to compiling from source using node-gyp—which requires specific build tools and libraries that aren't installed by default on macOS.

Here's how to fix this step-by-step:

1. Install macOS Build Tools

First, make sure you have Xcode Command Line Tools installed (these are required for compiling native modules):

xcode-select --install

Follow the on-screen prompts to complete the installation.

2. Install System Dependencies for canvas

Use Homebrew (install it first if you haven't already) to install the libraries canvas needs to compile:

# Install Homebrew if you haven't already
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install canvas dependencies
brew install pkg-config cairo pango libpng jpeg giflib librsvg

3. Clean Cache and Reinstall Dependencies

Clear any corrupted cache or partial installs, then start fresh:

# Navigate to your Metaplex CLI directory
cd /Users/yohan/metaplex/js/packages/cli

# Clear yarn cache
yarn cache clean

# Remove existing node_modules and lock files
rm -rf node_modules
rm -f yarn.lock package-lock.json

# Reinstall dependencies
yarn install

4. Fallback: Force Source Compilation (If Needed)

If the above steps still fail, you can force node-pre-gyp to compile from source instead of trying to download prebuilt binaries:

npm_config_build_from_source=true yarn install

This should resolve the gyp ERR! and node-pre-gyp ERR! errors you're seeing, since it ensures all required tools and libraries are present for the canvas package to build successfully.

内容的提问来源于stack exchange,提问作者하얀병아리

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.30 21:59:11