React-native: Can't find 'node' binary to build React Native bundle

Created on 9 Jan 2019  ·  6Comments  ·  Source: facebook/react-native

Environment

Environment:
OS: macOS 10.14.1
Node: 8.11.2
Yarn: Not Found
npm: 5.6.0
Watchman: 4.9.0
react-native: 0.55.4,
Xcode: Xcode 10.1 Build version 10B61
Android Studio: 3.2 AI-181.5540.7.32.5056338

Packages: (wanted => installed)
react: 16.3.1 => 16.3.1

Description

I cant build my app on iOS anymore,

```▸ Running script 'Bundle React Native code and images'

❌ error: Can't find 'node' binary to build React Native bundle```

Can you help? I have tried everything I could find on the previous issues

Bug Locked 📦Bundler

Most helpful comment

I was able to workaround the issue using this answer from StackOverflow

ln -s $(which node) /usr/local/bin/node

All 6 comments

I was able to workaround the issue using this answer from StackOverflow

ln -s $(which node) /usr/local/bin/node

Hey, this looks like an environment issue. 'Can't find node binary' is triggered when the Node.js installation is invalid. Try checking your path and the workaround mentioned. If you think this is an actual issue on RN side, provide us with a minimal repro and we'll have a look again.

I would recommend against symbolically linking your node binary; it can cause issues elsewhere. Instead set the binary within XCode as it suggests in the error:

image

For the people coming across this error that have added node args via the NODE_BINARY env variable (e.g. export NODE_BINARY='node --max_old_space_size=4096'), you should instead be setting NODE_ARGS:
export NODE_ARGS='--max_old_space_size=2048'

(as of https://github.com/facebook/react-native/pull/22423)

I actually semi-redact my previous comment. Although it works fine when there's only one person working on the project, it causes issues if more than one person wants to use the same xcode file. Also breaks things like appcenter.ms which has no knowledge of your local file structure!

@MaffooBristol sorry to disappoint you, but your proposed solution (xcode build phase - /usr/local/opt/node@12/bin/node) did not have any effect on my freshly created app, metro could not find a node binary; only creating the symbolic link proposed by @tristankenney eventually made it work.

xcode 11.3.1

Was this page helpful?
0 / 5 - 0 ratings