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
~/.profilethat setup the environment and add. ~/.profileat 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-cliThis fixed my issueI came up with the following simple solution:
ls /Users/kris/npmI confirm there is a
/binfolder with thereact-nativebinary inside…I then manually added
/Users/kris/npm/binto my$PATHexport PATH=$PATH:/usr/local/bin/:/Users/kris/npm/binIT WORKS!!!
My solution is simple if you’re using nvm: Run
nvm alias default nodebecause 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-packagesWarning .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
.xcodeprojis outside the iOS folder.If this is the case for you and you are manually adding
../node_modules/react-native/packager/react-native-xcode.shinto your Build Phases.make sure you first change it to
./node_modules/react-native/packager/react-native-xcode.shand 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_profileto./node_modules/react-native/packager/react-native-xcode.shto fix it.