Loading Now

Fixing Hermes Build Error in React Native 0.79.2+ (iOS)

If you’re seeing an error like:

Command PhaseScriptExecution failed with a nonzero exit code
Run script build phase '[CP-User] [Hermes] Replace Hermes for the right configuration, if needed'

This is likely related to Hermes’ build script not finding your Node binary correctly.


🛠 Root Cause

Hermes runs a script during the iOS build phase that requires access to the node executable. If you’re using nvm or a non-system Node install, Xcode may not find node, causing the script to silently fail.


🔍 Solution: Fix the NODE_BINARY path manually

  1. Open your iOS environment file:
    open ios/.xcode.env
  2. Locate the line:
    export NODE_BINARY=$(command -v node)
  3. Replace it with your actual node binary path:
    export NODE_BINARY=/Users/youruser/.nvm/versions/node/v18.15.0/bin/node

    You can find your Node path using:

    which node
  4. Save the file and rebuild your project:
    cd ios && pod install
    cd ..
    npx react-native run-ios --reset-cache

✅ Why this Works

Setting an absolute path ensures that Xcode knows exactly where to find node, regardless of your shell, terminal, or environment setup. It avoids relying on $PATH, which Xcode doesn’t load the same way your shell does.


📌 Bonus: Make it Project-Independent

If you’re working in a team or CI/CD pipeline, avoid hardcoding personal paths. Instead, consider adding documentation or scripts that auto-detect and inject the correct path based on the environment.


🔗 Source

Inspired by this comment: GitHub Issue #36762


Let me know if you need this styled as a blog post, Markdown for documentation, or want help integrating this into your CI/CD setup.

Share this content:

Post Comment

Bạn có thể đã bỏ qua