Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Xcode build error for react-native AwesomeProject #4034

Closed
L-Jovi opened this issue Nov 10, 2015 · 11 comments
Closed

Xcode build error for react-native AwesomeProject #4034

L-Jovi opened this issue Nov 10, 2015 · 11 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@L-Jovi
Copy link

L-Jovi commented Nov 10, 2015

I follow step but receive below output from Xcode 😢

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

could anybody rescue me? thx ..

@ide
Copy link
Contributor

ide commented Nov 10, 2015

This issue should be fixed in 0.14.2. Please try upgrading and close this issue if it's fixed for you.

@L-Jovi
Copy link
Author

L-Jovi commented Nov 10, 2015

@ide thanks, fix it 👍

@L-Jovi L-Jovi closed this as completed Nov 10, 2015
@brancusi
Copy link

Hi, I'm still getting this error. Just installed fresh today, package.json specifies 0.14.2.

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

react-native-cli is also installed globally.

$ react-native -v #0.1.7

Any ideas?

@brancusi
Copy link

If I add this to the shell file right above the call to react-native it builds:

PATH=${PATH}:/Users/aramz/.node/bin
$ which react-native #/Users/aramz/.node/bin//react-native

So my path is somehow messed up.

@arunshan
Copy link

@ide I am trying to start a new project and get the following error

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

@L-Jovi
Copy link
Author

L-Jovi commented Nov 12, 2015

previously I use nvm to manage node version, and this issue point that Xcode path can't find nvm path correctly, you could try my method below ..

open your react-native-xcode.sh which live [your project root location]/node_modules/react-native/packager, and add below two lines at begin.

source ~/.nvm/nvm.sh
nvm use stable

maybe current stable node version is v5.0.0, when you finished above try, re-run your Xcode.

hope make sense.

@ide
Copy link
Contributor

ide commented Nov 12, 2015

react-native-xcode.sh will source nvm.sh for you in RN 0.14.2. Perhaps you need to run nvm alias default node to make sure the sourcing actually does something?

@samueleaton
Copy link

I'm not seeing a nvm.sh in my ~/.nvm directory. I only see an alias, bin, nvm-exec and versions. That's probably why I'm getting a failed build. But I never did any modifications to nvm so this is weird.

EDIT: I also used homebrew to install it.
EDIT 2: I guess homebrew is the problem? #3037

@samueleaton
Copy link

I am confirming my second edit in my last comment. I uninstalled nvm from homebrew and installed it using the recommended curl method. Now it compiles.

@brianjd
Copy link

brianjd commented Nov 14, 2015

Had this issue, now resolved. It was a result of using prefix option (for installed packages) in npm configuration, which in turn was breaking nvm, which hosed the script.

nvm-sh/nvm#855

@lamberta
Copy link
Contributor

I ran into this issue and I'm not running nvm:

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

The react-native-xcode.sh script is run as $USER but it's not getting my environment $PATH. (I use the prefix config option in .npmrc)
Here's the $PATH var within react-native-xcode.sh:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/libexec:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/local/bin:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/usr/bin:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/usr/local/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/local/bin:/Applications/Xcode.app/Contents/Developer/Tools:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

As a workaround I added this right above the call to react-native bundle:

PATH="$(npm prefix -g)/bin:$PATH"

ghost pushed a commit that referenced this issue Dec 12, 2015
Summary:
Related to issue #4034 (comment).
The npm global install path may be set to a non-standard location. `react-native` is assumed to be in `PATH` but doesn't take into account the user's environment so building in Xcode fails:
~~~
react-native bundle --entry-file index.ios.js --platform ios --dev true --bundle-output [...]

../node_modules/react-native/packager/react-native-xcode.sh: line 48: react-native: command not found
Command /bin/sh failed with exit code 127
~~~
This fix uses `npm prefix -g` to get the bin location and adds it to `PATH`.
Closes #4749

Reviewed By: svcscm

Differential Revision: D2753215

Pulled By: androidtrunkagent

fb-gh-sync-id: 964d1a71ac1bf204545a594a9fa433a7bc367f35
cpojer pushed a commit to facebook/metro that referenced this issue Jan 26, 2017
Summary:
Related to issue facebook/react-native#4034 (comment).
The npm global install path may be set to a non-standard location. `react-native` is assumed to be in `PATH` but doesn't take into account the user's environment so building in Xcode fails:
~~~
react-native bundle --entry-file index.ios.js --platform ios --dev true --bundle-output [...]

../node_modules/react-native/packager/react-native-xcode.sh: line 48: react-native: command not found
Command /bin/sh failed with exit code 127
~~~
This fix uses `npm prefix -g` to get the bin location and adds it to `PATH`.
Closes facebook/react-native#4749

Reviewed By: svcscm

Differential Revision: D2753215

Pulled By: androidtrunkagent

fb-gh-sync-id: 964d1a71ac1bf204545a594a9fa433a7bc367f35
@facebook facebook locked as resolved and limited conversation to collaborators Jul 20, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 20, 2018
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

8 participants