Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

No bundle url present #12754

Closed
soutot opened this issue Mar 7, 2017 · 192 comments
Closed

No bundle url present #12754

soutot opened this issue Mar 7, 2017 · 192 comments

Comments

@soutot
Copy link

@soutot soutot commented Mar 7, 2017

Description

I noticed some people recently asking about this "No bundle url present" error and I just faced it myself.

Reproduction

I had just run ˜react-native init projectName˜, setup my App.js file (a simple Hello World), called it in both iOS and Android indexes and run ˜react-native run-ios˜. Then the No bundle url present error appeared.

Solution

I tried to delete my node_modules and npm install, close the packager and run the project again, but it could only be solved when I follow the steps given here (http://stackoverflow.com/questions/42610070/what-means-of-no-bundle-url-present-in-react-native).

  • Run "react-native run-ios"
  • When the error appears, run "npm install"
  • Then run "react-native run-ios" again.

Additional Information

This is the first project I started using RN 0.42. Since it never happened before and I am not the only one facing this issue, I guess it should be taken a closer look to it.

Here's my package.json:

{
	"name": "myProject",
	"version": "0.0.1",
	"private": true,
	"scripts": {
		"start": "node node_modules/react-native/local-cli/cli.js start",
		"test": "jest"
	},
	"dependencies": {
		"react": "~15.4.1",
		"react-native": "0.42.0"
	},
	"devDependencies": {
		"babel-jest": "19.0.0",
		"babel-preset-react-native": "1.9.1",
		"jest": "19.0.2",
		"react-test-renderer": "~15.4.1"
	},
	"jest": {
		"preset": "react-native"
	}
}

If I can be more helpful to make any further test, it would be a pleasure.

@edwardofclt
Copy link

@edwardofclt edwardofclt commented Mar 7, 2017

Having the same issue now. Not sure what changed.

@decadef20
Copy link

@decadef20 decadef20 commented Mar 8, 2017

Same problem.

@edwardofclt
Copy link

@edwardofclt edwardofclt commented Mar 8, 2017

@skv-headless
Copy link
Contributor

@skv-headless skv-headless commented Mar 8, 2017

What if you run npm start in console?

@qyvip
Copy link

@qyvip qyvip commented Mar 8, 2017

Same problem.

I found
JsCodeLocation = [[RCTBundleURLProvider jsBundleURLForBundleRoot:@ sharedSettings] "index.ios" fallbackResource:nil];
Take effective address not, this happens in connection to the network situation (and not all networks such), when this happens, disconnected from the network, I think, in a virtual machine can run in localhost:8081
This is the way I am

@edwardofclt
Copy link

@edwardofclt edwardofclt commented Mar 8, 2017

@edwardofclt
Copy link

@edwardofclt edwardofclt commented Mar 8, 2017

@qyvip
Copy link

@qyvip qyvip commented Mar 8, 2017

@AbeHerbert

Yes, this is the IOS code, I simply look at the code, here will automatically take the local IP, but obviously, did not take, Android I have not tried, but this is obviously different from the IOS code

My situation when I changed a network environment, it is normal, very clever, when I met the home
I try to print out the automatic access to the full address, are taken to return to the null, at the same time, APP will be waiting for the start of the case, this is the local address

NSLog (@ absoluteString:%@), [jsCodeLocation absoluteString]);
NSLog (@ host:%@), [jsCodeLocation host]);
NSLog (@ port:%@), [jsCodeLocation port]);

When I will

jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];

Modified into

jsCodeLocation = [NSURL URLWithString:@"http://127.0.0.1:8081/index.ios.bundle?platform=ios&dev=true"];

This time can be a normal start, but after entering the application of remote image loading, it seems wrong
This is just a point of view, and there is no concrete solution

@rmevans9
Copy link
Contributor

@rmevans9 rmevans9 commented Mar 8, 2017

I have gotten that message when the packager is not running when the app is launched on iOS. Typically I have to completely kill the app and launch again after I have started the packager. Can you guys be sure that you have the packager running prior to launching the app?

@soutot
Copy link
Author

@soutot soutot commented Mar 8, 2017

@rmevans9 in my case the packager was running as always. The solution I posted is done while the packager and the app are running. That's the only way I found by now to handle this. I belive there's something going wrong when the modules are installed on react-native init. I have to do some tests before assurance it

@qyvip
Copy link

@qyvip qyvip commented Mar 8, 2017

Yes, the packager is already running. I can access it through the browser

@despreston
Copy link

@despreston despreston commented Mar 8, 2017

I am also seeing this issue on RN 0.42.0

@liqueflies
Copy link

@liqueflies liqueflies commented Mar 8, 2017

+1

@Mess1ah
Copy link

@Mess1ah Mess1ah commented Mar 9, 2017

Same problem and I run "npm install" and "react-native run-ios" ,the problem seems to be not solved yet.

@yustada
Copy link

@yustada yustada commented Mar 9, 2017

I am seeing same problem @0.42.0 and
"npm install" does not solve it.

@yustada
Copy link

@yustada yustada commented Mar 9, 2017

My problem has been solved by adding NSAllowsLocalNetworking to Info.plist

<key>NSAppTransportSecurity</key>
	<dict>
		<key>NSAllowsArbitraryLoads</key>
		<true/>
		<key>NSAllowsArbitraryLoadsInWebContent</key>
		<true/>
		<key>NSAllowsLocalNetworking</key>
		<true/>
	</dict>
</key>

I am not sure it is because of RN0.42 or iOS issue, but it is solved in my case.

@akiver
Copy link

@akiver akiver commented Mar 12, 2017

Check if you have 127.0.0.1 localhost in your hosts, clean the project and retry, it worked for me.

@edwardofclt
Copy link

@edwardofclt edwardofclt commented Mar 12, 2017

@shivashp
Copy link
Contributor

@shivashp shivashp commented Mar 13, 2017

I found a working solution, Give it a try. While the simulator is running don't close your bundler. Go to the path and run npm install then again react-native run-ios. It started working for me.

@adamnator92
Copy link

@adamnator92 adamnator92 commented Mar 13, 2017

i faced this issues after i moved my project to another directory and run ios simulator

@jaxondu
Copy link

@jaxondu jaxondu commented Mar 13, 2017

This is working for me: leave simulator running, leave the packager terminal window on, and run react-native run-ios again.

@powercoder23
Copy link

@powercoder23 powercoder23 commented Mar 13, 2017

This also means the "Port already in use"

Terminating a process on port 8081

Run the following command on a Mac to find the id for the process that is listening on port 8081:

$ sudo lsof -i :8081

Then run the following to terminate the process:

$ kill -9 <PID>

please try troubleshooting in below link
https://facebook.github.io/react-native/docs/troubleshooting.html

Thanks,
Dhiraj

@cesarkawakami
Copy link

@cesarkawakami cesarkawakami commented Mar 14, 2017

I'm just leaving this here, in case other people stumble upon the same cause.

In our team's case, during the migration to 0.42.0, we've accidentally removed the "Bundle React Native code and images" build phase from the XCode project.

Manually re-adding the phase solved the problem, but we're left scratching our heads as to when or how the phase was removed.

sglearner_xcodeproj

@stantoncbradley
Copy link

@stantoncbradley stantoncbradley commented Mar 14, 2017

works for me when I build the app through xcode...

@grundmanise
Copy link

@grundmanise grundmanise commented Mar 16, 2017

Same issue. Have set scheme to Release in Xcode and trying to archive the app for production, but main.jsbundle is not generating...

@cutemachine
Copy link

@cutemachine cutemachine commented Mar 16, 2017

I had the same error and was able to run the app only through Xcode. react-native run-ios did not work. To resolve the issue you need to remove the build folder YOUR_PROJECT/ios/build/. After this you should be able to run your app through react-native run-ios again. Hope this helps.

@pkral78
Copy link

@pkral78 pkral78 commented Mar 16, 2017

For Debug configuration, which is default when new project is generated with react-native init command, build does not generate bundle file but instead uses packager for that. So the issue is related to network settings and is very likely related to proxy settings. If proxy is used, do not forget to set bypass proxy for localhost and 127.0.0.1 addresses.

@gperdomor
Copy link
Contributor

@gperdomor gperdomor commented Mar 16, 2017

Same here... Install the node packages again is not a proper solution

@archywillhe
Copy link

@archywillhe archywillhe commented Mar 16, 2017

In my case it was because I was running Shadowsocks (being in China at the moment) and I didn't set it to bypass 127.0.0.1 and localhost. Thanks @om2pkral for mentioning that.

@yoonchulkoh
Copy link

@yoonchulkoh yoonchulkoh commented Mar 18, 2017

In my case, nothing was displayed on the other terminal that started up when react-native run-ios was executed.
It means that packager is not running.

So I was able to start packager by running PROJECT_DIR/node_modules/react-native/packager/launchPackager.command myself.
I run react-native run-ios again, it started up normally.

I don't know the cause, but the behavior of the open command below is doubtful.

shellScript = "if [ -z \"${RCT_NO_LAUNCH_PACKAGER+xxx}\" ] ; then\nif nc -w 5 -z localhost 8081 ; then\nif ! curl -s \"http://localhost:8081/status\" | grep -q \"packager-status:running\" ; then\necho \"Port 8081 already in use, packager is either not running or not running correctly\"\nexit 2\nfi\nelse\nopen \"$SRCROOT/../packager/launchPackager.command\" || echo \"Can't start packager automatically\"\nfi\nfi";

@jjdraijer
Copy link

@jjdraijer jjdraijer commented Jan 19, 2018

Try to

npm install metro

Solved it because of a bug

@shadowbrush
Copy link

@shadowbrush shadowbrush commented Jan 23, 2018

If anyone wants a script for turning on/off the transport security in Info.plist:

    var fs = require('fs');
    var plist = require('plist');

    function modifyIosTransportSecurity(plistPath, enable) {
      var info = plist.parse(fs.readFileSync(plistPath, 'utf8'));
      info.NSAppTransportSecurity.NSAllowsArbitraryLoads = !enable;
      info.NSAppTransportSecurity.NSAllowsArbitraryLoadsInWebContent = !enable;
      info.NSAppTransportSecurity.NSAllowsLocalNetworking = !enable;
      fs.writeFileSync(plistPath, plist.build(info));
    }

I'm calling this from a pre- and post-build script that were added to XCode's build phases.

@KangYoosam
Copy link

@KangYoosam KangYoosam commented Jan 23, 2018

There are two apps(same project) on the simulator. Once I delete the new one, problem got resolved.

@OrangeFlavoredColdCoffee
Copy link

@OrangeFlavoredColdCoffee OrangeFlavoredColdCoffee commented Jan 24, 2018

image

if you check this, Xcode cannot log some error ..uncheck it and find error
''undefined is not an object( evaluating '_reactNative.ViewPropTypes.style')''

and do like this:

1 import ViewPropTypes from react-native
2change View.propTypes to ViewPropTypes

and it work for me .
if you recently update your RN version ,you may have this .

i had this error only release mode. and dev mode work fine ..i have tried solutions nearly all above .but none works.

:
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];

"react": "16.0.0-alpha.12",
"react-dom": "16.0.0-alpha.12",
"react-native": "0.51.0",

and a few days ago ,just update 0.44 to 0.51.0 . if this issues cant fixed. i will roll back to lower version have a try .

@shaunsaker
Copy link

@shaunsaker shaunsaker commented Jan 29, 2018

Not sure if this will help you guys but I changed my build config in Xcode (Product => Scheme => Edit Scheme) back to Debug and it worked.

@infinito84
Copy link

@infinito84 infinito84 commented Feb 1, 2018

This work for me:

react-native link
react-native run-ios
@miniyarov
Copy link

@miniyarov miniyarov commented Feb 4, 2018

Based on this thread and some other there are a lot of errors causing this problem.
But mine was related with localhost domain. So make sure you have set 127.0.0.1 localhost in your /etc/hosts for Linux/Unix or equivalent file on Windows.

@bagana89
Copy link

@bagana89 bagana89 commented Feb 8, 2018

if your project opened by xcode. please close the xcode and run again, it works for me

@nabil-mansouri
Copy link

@nabil-mansouri nabil-mansouri commented Feb 18, 2018

Hi guys,
I solved it on my device by replacing on AppDelegate.m:

jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];

By:

http://IP_ADDRESS_ON_MY_LAN:8081/index.ios.bundle?platform=ios&dev=true

Where IP_ADDRESS_ON_MY_LAN = 192.168....

@monkingame
Copy link

@monkingame monkingame commented Mar 1, 2018

I met the same issue after build release version(under ios).
I changed the followings and got normal result.
1)change AppDelegate.m codes:
comment
jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
and uncomment
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
2)re-enable ATS localhost in Info.plist
App Transport Security Settings -> Excepiton Domains -> localhost -> NSExceptionAllowsInsecureHTTPLoads -> TRUE
3)run react-native run-ios again and reload the app in simulator

@JohnSmith0602
Copy link

@JohnSmith0602 JohnSmith0602 commented Mar 3, 2018

@monkingame Thx, the localhost part saved my day!

@FrankSandqvist
Copy link

@FrankSandqvist FrankSandqvist commented Mar 3, 2018

@monkingame Thanks, the changing of comments worked for me. I have no idea what caused this error to start happening to begin with, started after I made the production build and wanted to back to debugging. How did that change the code location?

@originalix
Copy link

@originalix originalix commented Mar 8, 2018

This work for me.

rm -rf ios/build
react-native run-ios
@marcelotadeujr
Copy link

@marcelotadeujr marcelotadeujr commented Mar 11, 2018

This work for me.

rm -rf ios/build/; kill $(lsof -t -i:8081);
react-native run-ios
@alangumer
Copy link

@alangumer alangumer commented Mar 13, 2018

run
yarn start or npm start
to start the development server

if necessary run again:
react-native run-ios

https://stackoverflow.com/a/48016926/4636856

@lucidtheory
Copy link

@lucidtheory lucidtheory commented Mar 20, 2018

For me for some reason the jsCodeLocation changed in AppDelegate.m

make sure it is
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];

@GemN
Copy link

@GemN GemN commented Mar 22, 2018

From another thread after trying everything, that solution worked:

"this is solved my issue:
info.plist → information Property List → + App Transport Security Settings → + Allow Arbitrary Loads = YES"

@rishabh-saxena
Copy link

@rishabh-saxena rishabh-saxena commented Mar 24, 2018

I got it resolved by including the below code in Info.plist file which I had removed from the production build.
<key>NSAppTransportSecurity</key> <dict> <key>NSExceptionDomains</key> <dict> <key>localhost</key> <dict> <key>NSExceptionAllowsInsecureHTTPLoads</key> <true/> </dict> </dict> </dict>

@mikenk2010
Copy link

@mikenk2010 mikenk2010 commented Mar 27, 2018

Easy boy, just remove ios/build (rm -rf ios/build) then run react-native run-ios again! Take me 30m to figure out...LOL...

@yogeshR5
Copy link

@yogeshR5 yogeshR5 commented Apr 3, 2018

@jiteshwadia same problem occurred to me.
what I have to do now??

@bjacobs09
Copy link

@bjacobs09 bjacobs09 commented Apr 5, 2018

For me, I was having a problem with Node not being recognized in any new tab opened. So I have to use nvm use in every new tab. Because the bundler was opening in a new tab when I ran npm run ios, it wasn't seeing Node. And I can't type in that bundler terminal for some reason.

So my solution was in one tab run nvm use 8.9.3 or whatever version you're on, then in that tab run npm start. Then open a new tab and do nvm use 8.9.3 and in that tab run npm run ios or however you run your simulator.

@LuckyCrab
Copy link

@LuckyCrab LuckyCrab commented Apr 16, 2018

This work for me.

react-native bundle --entry-file='index.js' --bundle-output='./ios/main.jsbundle' --dev=false --platform='ios' --assets-dest='./ios'
@Air-Rands
Copy link

@Air-Rands Air-Rands commented Apr 29, 2018

I had the same issue and after trying everything here qyvip's answer lead me to the right one.
In the ios>"Your Main Project Folder">AppDelegate.m .

update
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];

to be
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];

@miksansegundo
Copy link

@miksansegundo miksansegundo commented May 5, 2018

This worked for me. Check that your main.jsbundle is targeted to your main Project.
I also had to clean the caches.
image

@tayfunyasar
Copy link

@tayfunyasar tayfunyasar commented May 22, 2018

Adding NSAllowsArbitraryLoads: true solved my problem.

@facebook facebook locked as resolved and limited conversation to collaborators May 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.