React Native: Cannot run program “node” error=2, No such file or directory
🛠️ Fix Node.js Not Found in Android Studio by Using $ open -a "Android Studio.app"
If you’re building a React Native app on macOS and see this error in Android Studio:
It usually means Android Studio can’t find your Node.js installation because it was launched without inheriting your shell environment (like nvm
or Homebrew path).
✅ The Fix (1 Line):
Instead of opening Android Studio from Launchpad or Dock, run this in Terminal:
This makes Android Studio inherit the correct PATH
, including access to node
.
💡 Why it works:
When opened via Terminal, macOS passes your shell environment (including nvm
, brew
, etc.) to Android Studio. This allows Gradle to locate the node
binary during the React Native build.
🧠 Tip:
You can even make a small shell alias to make it faster:
Add that to your ~/.zshrc
or ~/.bash_profile
, and next time just run:
Done!
Share this content:
Post Comment