New RN project in M1 mbp built failed. "Could not find node. Make sure it is in bash PATH or set the NODE_BINARY environment variable."

pekanchuan picture pekanchuan · Apr 30, 2021 · Viewed 7.5k times · Source
System:
    OS: macOS 11.3
    CPU: (8) arm64 Apple M1
    Memory: 124.86 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.0.0 - /opt/homebrew/bin/node
    Yarn: Not Found
    npm: 7.10.0 - /opt/homebrew/bin/npm
    Watchman: Not Found
  Managers:
    CocoaPods: 1.10.1 - /Users/chia/.rbenv/shims/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
    Android SDK: Not Found
  IDEs:
    Android Studio: Not Found
    Xcode: 12.5/12E262 - /usr/bin/xcodebuild
  Languages:
    Java: Not Found
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.1 => 17.0.1 
    react-native: 0.64.0 => 0.64.0 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

New RN project create successful, but built failed by Xcode.

Error:

Error: Could not find node. Make sure it is in bash PATH or set the NODE_BINARY environment variable.

Command PhaseScriptExecution failed with a nonzero exit code

node installed by homebrew, and Intel mbp doesn't have this error.

How to resolve this error?

Node in the PATH

npm -g bin /opt/homebrew/bin

echo $PATH /Users/chia/.pyenv/shims:/Users/chia/.rbenv/shims:/Users/chia/.rbenv/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin

Answer

pekanchuan picture pekanchuan · May 1, 2021
sudo ln -s $(which node) /usr/local/bin/node

It resolved.