Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React native error - react-native-xcode.sh: line 45: react-native: command not found Command /bin/sh failed with exit code 127

I get this error when trying to build any (new or old) project. My node is on version 4.2.1 and react-native is on version 0.1.7. I've looked at other people with the same problem so I've updated react-native to the latest version however I still cannot build any project through xcode.

like image 435
Jacob Avatar asked Nov 11 '15 12:11

Jacob


People also ask

Why react native command is not working?

Why am I seeing “command not found: react-native”? If you are getting this error, it means that either you do not have the CLI installed on your machine, or you do not have it configured properly.

How do I delete Fbreactnativespec?

I've faced the following error when I want to start the IOS app with the "react-native run-ios" command. If I start the debug build from XCode, it is started successfully. Run unset npm_config_prefix to unset it. Run unset npm_config_prefix to unset it.

How do I run react native information?

Running your React Native application Install the Expo Go app on your iOS or Android phone and connect to the same wireless network as your computer. On Android, use the Expo Go app to scan the QR code from your terminal to open your project. On iOS, use the built-in QR code scanner of the default iOS Camera app.


1 Answers

If you are using RN 0.46 or above:

There is a breaking change made by Facebook: the location of the script has been changed, more detail here

I was able to solve this error by:

  • Opening the project in XCode
  • Navigate to Build Phases > Bundle React Native code and images
  • Change export NODE_BINARY=node ../node_modules/react-native/packager/react-native-xcode.sh to export NODE_BINARY=node ../node_modules/react-native/scripts/react-native-xcode.sh

Notice how packager is now scripts, which is where that file actually lives in latest version of RN

enter image description here

like image 82
Darius Avatar answered Oct 15 '22 23:10

Darius