I'm working on a React Native project, and when I try to build the app for the iOS emulator using Xcode, I get the following error:
Node found at: /opt/homebrew/Cellar/node/23.4.0/bin/node
/Users/myusername/Library/Developer/Xcode/DerivedData/myprojectname-djumxyhefghbyxhakbfulqsiabcd/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/hermes-engine.build/Script-46EB2E0002AE70.sh: line 9: /opt/homebrew/Cellar/node/23.4.0/bin/node: No such file or directory
Command PhaseScriptExecution failed with a nonzero exit code
Issue:
Xcode is referring to an outdated Node.js path (/opt/homebrew/Cellar/node/23.4.0/bin/node), but I have the correct version installed at:
/opt/homebrew/Cellar/node/23.10.0_1/bin/node
I also tried updating my xcode.env file with:
export NODE_BINARY=/opt/homebrew/Cellar/node/23.10.0_1/bin/node
Running which node and node -v to verify that my terminal is using the correct Node.js version.
Updating the Build Phases → Bundle React Native Code and Images script in Xcode to explicitly set the Node.js path:
export NODE_BINARY=/opt/homebrew/Cellar/node/23.10.0_1/bin/node
Cleaning the build folder (Product > Clean Build Folder) and restarting Xcode.
Checking ~/.zshrc and ~/.bashrc to ensure my shell environment is correctly configured.
How can I make sure Xcode consistently uses the correct Node.js path when building my React Native iOS app?
Any help would be appreciated! 🚀