react-native: react-native: command not found
I’ve bootstrapped a new react-native project with the latest react-native-cli and when I try to run it in XCode, I get:
../node_modules/react-native/packager/react-native-xcode.sh: line 36: react-native: command not found
That means I can not anymore run a react-native 0.14 app in my system.
So if I understand this correctly, XCode is calling a shell script. But I’m using nvm and my react-native
is not global (unless executing some env files), so I guess xcode don’t execute my env? Also i’m using ZSH.
I feel that the packager should not expect react-native
command to exist because it really depend on the env config of each developer and we will likely have a lot of issues like this.
Why is there a strong dependency from react-native packager to react-native-cli ? Someone that fork a react-native example/project should be able to just run it without having to install react-native-cli separately
Workaround: create a
~/.profile
that setup the environment and add. ~/.profile
at the beginning of./node_modules/react-native/packager/react-native-xcode.sh
… Unfortunately I don’t see a way to setup this in XCode.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 54 (9 by maintainers)
Try to do this:
$ npm install -g react-native-cli
This fixed my issueI came up with the following simple solution:
ls /Users/kris/npm
I confirm there is a
/bin
folder with thereact-native
binary inside…I then manually added
/Users/kris/npm/bin
to my$PATH
export PATH=$PATH:/usr/local/bin/:/Users/kris/npm/bin
IT WORKS!!!
My solution is simple if you’re using nvm: Run
nvm alias default node
because each time a new Terminal comes about, it was defaulting to system node.I have solved this problem by adding lines:
to Xcode build settings in ‘Build Phases’ -> ‘Bundle React Native code and images’ right before
@kristianmandrup like:
ls /Users/burak/.npm-packages
Warning .npm-packages Its worked trying this code:export PATH=$PATH:/Users/burak/.npm-packages/bin/
I had this project before Android feature came out, and my
.xcodeproj
is outside the iOS folder.If this is the case for you and you are manually adding
../node_modules/react-native/packager/react-native-xcode.sh
into your Build Phases.make sure you first change it to
./node_modules/react-native/packager/react-native-xcode.sh
and inside react-native-xcode.sh remove the linecd ..
It confuses me when owners/contributors close issues like this one when they clearly aren’t resolved. 😦
But anyway, I also had to add
source ~/.bash_profile
to./node_modules/react-native/packager/react-native-xcode.sh
to fix it.