Xcode cannot find node when building a React Native iOS app
Can't find nodeShort answer
Xcode runs the React Native bundle script without your terminal's PATH, so it needs a path to node. The script reads NODE_BINARY from ios/.xcode.env, then ios/.xcode.env.local. Put export NODE_BINARY=$(command -v node) in one of them, or load nvm from ~/.zshenv, then clean and build again.
Fix it fast
1Find out which cause you have
Print the node path your terminal uses, and see what the project file says. The build log line 'Node found at:' shows which path Xcode actually got.
command -v node cat ios/.xcode.env cat ios/.xcode.env.local2Match what you see, then jump to its fix
- 1
[Warning] You need to configure your node path in the ".xcode.env" file environmentNODE_BINARY is not set for XcodeFix - 2
No such file or directory for a node path that you or a teammate typed into .xcode.env or .xcode.env.localA hard-coded node path went stale after a Node upgradeFix - 3
command -v node works in Terminal but the Xcode build cannot find itnode comes from nvm and zsh does not load it for XcodeFix - 4
Terminal builds work and the Xcode build phase fails right at the startA build phase script does not use zshFix
- 1
What does the error look like?
Can't find node[Warning] You need to configure your node path in the ".xcode.env" file environment.
Cause 1 of 4
NODE_BINARY is not set for Xcode
1Check
The script starts with NODE_BINARY=$(command -v node) using Xcode's own PATH. If that finds nothing and .xcode.env does not set it, the script prints the warning and falls back to an old lookup that is marked for removal.
ls -a ios | grep xcode.env2Fix
Create ios/.xcode.env with the node path from your terminal. Use command -v node, not a typed path, so the line also works on another machine.
cd ios
echo 'export NODE_BINARY=$(command -v node)' > .xcode.env3Verify
Clean the build folder in Xcode (Product > Clean Build Folder) and build again. The build log shows 'Node found at:' followed by a path.
# In the Xcode report navigator, open the 'Bundle React Native code and images' step and look for: Node found at:Confirmed by raw.githubusercontent.com
Cause 2 of 4
A hard-coded node path went stale after a Node upgrade
1Check
Both files are sourced after the default lookup, and .xcode.env.local is sourced last, so a fixed path in either file wins over the real one. Check that the path in those files still exists.
grep NODE_BINARY ios/.xcode.env ios/.xcode.env.local
ls -l "$(command -v node)"2Fix
Replace the typed path with the command -v form, or remove the stale line from .xcode.env.local.
# ios/.xcode.env.local
export NODE_BINARY=$(command -v node)3Verify
Build again and read the 'Node found at:' line in the log.
# Xcode report navigator > Bundle React Native code and imagesConfirmed by raw.githubusercontent.com
Cause 3 of 4
node comes from nvm and zsh does not load it for Xcode
1Check
The React Native setup guide says that with nvm and zsh, Xcode needs the nvm lines in ~/.zshenv. Look at where they are now.
grep -n nvm ~/.zshrc ~/.zshenv 2>/dev/null2Fix
Move the nvm initialisation from ~/.zshrc to ~/.zshenv.
# ~/.zshenv
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"3Verify
Quit Xcode fully, open it again, clean the build folder and build.
grep -n nvm ~/.zshenvConfirmed by reactnative.dev
Cause 4 of 4
A build phase script does not use zsh
1Check
In Xcode, open the app target, then Build Phases, and read the Shell field of every Run Script phase.
grep -n 'shellPath' ios/*.xcodeproj/project.pbxproj2Fix
The setup guide asks for /bin/zsh as the shell of every shell script build phase. Change any phase that uses another shell.
# Xcode > target > Build Phases > Run Script > Shell: /bin/zsh3Verify
Build again.
grep -n 'shellPath' ios/*.xcodeproj/project.pbxprojConfirmed by reactnative.dev
How do I stop it coming back?
- Keep export NODE_BINARY=$(command -v node) in ios/.xcode.env and commit it; use ios/.xcode.env.local only for a machine-specific override.
- Do not type a version-specific node path into either file; it breaks at the next Node upgrade.
- Use Node 22.11.0 or newer, the minimum the React Native setup guide lists.
- On CI, install Node in the job before the Xcode step.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.
Related fixes
Mobile apps
Xcode says a script phase failed, but not which one or why
error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.
This line only reports that one Run Script build phase exited with an error.
4 causes, each with a fixMobile apps
pod install fails with 'Invalid Podfile file: no implicit conversion of nil into String'
[!] Invalid `Podfile` file: no implicit conversion of nil into String.
A React Native Podfile starts by running node to find react_native_pods.rb.
2 causes, each with a fixMobile apps
Xcode release build fails because Metro did not produce main.jsbundle
Your environment is misconfigured as Metro was not able to produce the bundle so your release application won't work!
The Xcode build phase asks Metro for a JavaScript bundle, and the build fails when that bundle was not written.
3 causes, each with a fixMobile apps
Running pod on a React Native project fails with can't find gem cocoapods
can't find gem cocoapods (>= 0.a) with executable pod
The pod command exists, but the Ruby that is running it has no CocoaPods gem.
3 causes, each with a fixMobile apps
Gradle cannot run node in a React Native Android build
Process 'command 'node'' finished with non-zero exit value 1
The React Native Gradle plugin starts node for bundling.
3 causes, each with a fixMobile apps
Axios request works on iOS or in a browser but fails on Android with Network Error
AxiosError: Network Error
A React Native app has no CORS, so on Android a Network Error usually means the request never reached the server.
3 causes, each with a fix