By Yingch Xue


2017-03-05 15:16:48 8 Comments

When I run a react-native project, I get a error no bundle URL present , but I don't know what mistakes I do, I was very confused.

enter image description here

30 comments

@Arun Kandregula 2019-03-15 12:07:45

This problem may happen when we have multiple versions of node managed by nvm and default version is not intended version to run react-native. (make sure it is Node 8.3 or newer)

react-native run-ios

opens a new terminal and runs the version of node found in the $PATH.

If it finds an older version of node not supported by react native, it may give this error.

Make sure, the $PATH variable is already pointing to intended version of node(make sure it is Node 8.3 or newer) when a new terminal is opened.

That solved the issue for me. Good luck.

@SoftwareTheory 2019-03-14 20:54:05

This is how I did it:

  • Open a terminal window
  • cd into YOUR_PROJECT/ios
  • Remove the build folder with rm -r build
  • Run react-native run-ios again

@Kusal Kithmal 2019-01-25 09:02:25

Try running this code ---

sudo xcodebuild -license

This may fix the issue. This works for me.

@Prakash salawria 2019-01-25 07:15:45

Just run in Terminal react-native start:

cd your react native app directory/ react-native start 

It will start up the packager, now don't close this terminal window, in another terminal window run your project. This is the only want that I found to get it working properly.

@mikeh 2019-01-15 06:52:46

We got around this by removing the SKIP_BUNDLING option in the build script that the RN docs suggested adding to speed up the debug build. The real fix (for our cause) is included in RN 0.57:

https://github.com/facebook/react-native/issues/20553

@WiRa 2019-01-08 08:17:52

I was connected to the network by cable and wifi on my macbook, disabled wifi and just hit run and it worked!

@Techmaddy 2018-12-03 03:21:54

export FORCE_BUNDLING=true worked for me. There was a warning in the console that it was not getting bundled.

@Serdar De─čirmenci 2017-11-21 01:03:42

Be sure that your ATS settings are correct in .plist file.

You can find the file at /ios/{{project_name}}/Info.plist

localhost must be defined as exception request target like this:

<key>NSAppTransportSecurity</key>
    <dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>localhost</key>
        <dict>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
        </dict>
    </dict>
</dict>

*(dont forget to remove this on release version..)

@Tarik Chakur 2018-10-19 13:36:38

This one works for me. I did delete this lines from my plist file in iOS for production purpose, as a consequence The simulator couldn't fetch the bundle file. https://medium.com/@joshuakuhar/no-bundle-url-present-69333bb5da42

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>localhost</key>
        <dict>
        <key>NSExceptionAllowsInsecureHTTPLoads</key>
        <true/>
        </dict>
    </dict>
</dict>

@G. Adnane 2018-07-28 21:08:00

try to add this :

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

@cwRichardKim 2017-04-05 05:33:30

As instructed in the error message:

Agreeing to the Xcode/iOS license requires admin privileges, please run "sudo xcodebuild -license" and then retry this command.

...I ran the following command:

sudo xcodebuild -license

It works now.

@Hau Le 2018-06-19 07:43:54

For my use case, i had to remove node_modules directory and run npm install.

$ rm -rf node_modules   (make sure you're in the ios project directory)
$ npm install

If you get error "dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.58.dylib", do the following:

$ brew uninstall --force node --ignore-dependencies node
$ brew uninstall icu4c --ignore-dependencies icu4c
$ brew install icu4c
$ brew unlink icu4c && brew link icu4c --force
$ brew install node

$ npm install

@Pramodya Abeysinghe 2018-03-20 17:21:47

first close the simulator, then run these on terminal

npm install

react-native run-ios

@Divye Shah 2018-02-24 21:15:05

Use the command react-native bundle --platform ios --dev false --entry-file index.js --bundle-output ./ios/release/main.jsbundle --assets-dest ./ios/release/main.jsbundle

@Edoardo 2018-02-14 16:21:50

...another reason why this is happening is if you have installed Visual Studio Code React Native Tools but you keep trying to use react native in the terminal: it will work the first time but then it will stop and show you the red no bundle screen.

launching react native from vscode works perfectly instead...

@Witalo Benicio 2018-01-27 02:21:32

This problem happens when you not allow unsecure connections via localhost, or maybe you tried to accept unsecure connections via http.

To fix this, add this on info.plist:

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

@Darius 2018-04-12 12:04:02

What a hero this guy is. Saved me and my macbook from jumping out the window! I had changed my exception domain from localhost to my local network address in Info.plist and hence it was not resolving. I added a block for 'localhost' as an exception domain and it worked.

@Abraham Jagadeesh 2018-01-14 03:42:58

I had this same issue. But my problem was my Mac and iPhone were not in same wifi network.

So ensure that they are all in same network and rebuild once again. If this is not the case, try the solutions mentioned by other members here.

@parse 2018-01-04 14:37:18

Had same problem when I did bundle my app. Check that your main.jsbundle is targeted to your main Project

@Bap 2018-02-16 21:26:44

That was the only solution that worked for me

@Khoa 2017-12-29 03:05:19

Reason:

This is because the app cannot find out the server (which serves the UI - by javascript code).

Solution:

  • Make sure everything related to react native closed (not necessary, just to have clean start for my solution, after my explanation, you can figure out this is needed or not)
  • run npm run start or yarn start first
  • wait for this command done job (usually you will see Loading dependency graph, done.)
  • run react-native run-ios/android

Explanation:

  • React Native comes with 2 parts:

    • Native part
    • Javascript part
  • Build commands:

    • react-native run-ios/android is to build native part then deploy to devices and start app on devices (simulator/emulator/real device). This usually took 3~4 mins to finish.

    • npm run start or yarn start is to build the javascript part and start the dev server to serve the built UI to the app. This usually took 30 secs to finish.

=> Normally, the javascript part finished first then the native part came later. (based on time they used).

=> this is only true for the first time build (fresh build).

=> for re-build:

  • The native part just took 10~15 secs to check changes and because no change for native part => done before the javascript part was built and served. (I am not sure the javascript part was rebuilt or not but it took long time than native part)

  • So that is why we had this issue, the app ran and required thing that did not exist yet.

Bonus:

  • react-native run-ios/android will auto start the dev server for you.
  • That's why when you ran react-native run-ios/android right after react-native init <app_name>, everything ran well. (because auto start feature and the time was took for fresh build as state above).
  • Other "removing" solutions worked because they forced rebuilding.

Time used on this answer was relative to my machine => may different on others.

@Eliran Goshen 2017-12-22 13:14:27

another thing that working for me , is to open the project in xcode, and then clean and build it. usually it reruns the packaging server and solve the problem.

@Jared Chen 2017-12-22 05:46:23

It's because your client cannot reach your packager server.

If you are a Chinese Coder just as I am, I think you might using VPN get through the GFW. When your VPN tool is in 'Global Mode', all your request will travel through the world and cannot get localhost

Try 'Auto Proxy Mode'.

If you are not come from China, or your VPN setting is already 'Auto Proxy Mode', I suggest you shut down your packager server and try again.

@Bruce Lee 2017-11-03 10:42:28

I'm working with RN 0.49.5. I've tried lots of methods, but no one works. Finally i worked this out. It's simple and easy.

Main idea is to change the localhost to 127.0.0.1, but it's not where the RN tells you. It's in RCTBundleURLProvider.m#- (BOOL)isPackagerRunning:(NSString *)host.

Changes of code: oc - NSString *host = ipGuess ?: @"localhost"; + NSString *host = ipGuess ?: @"127.0.0.1"; This is ok for simulator. If it's device, just change the ip address to your machine's.

@Jane 2017-11-03 06:28:41

  1. check your hosts that 127.0.0.1 localhost is not delete
  2. check that the network agent is not set up
  3. then npm install & react-native upgrade to reset your project

@Vivek 2017-10-09 10:05:35

Most of the cases this problem occurs when the DNS lookup / IP lookup fails to find localhost.

Solution :

Try adding the localhost ip to your etc host file.

you can add the below lines to your etc host file (/etc/hosts)

127.0.0.1 localhost

255.255.255.255 broadcasthost

::1 l . ocalhost

To confirm this is the issue you can hit the bundle url on safari (if you try it in chrome this will resolve but safari won't be able to resolve it). http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false

@jeffctown 2018-07-21 12:47:59

After migrating to a brand new computer, this was what I needed. TY!

@Toby Flemming 2017-09-20 23:15:17

I have found the easiest/quickest way to bypass this is to exit the app within the simulator (2 x Cmd + Shift + H) and re-launch.

@PhillipOReilly 2018-08-06 22:46:21

Any idea WHY that works? That did the trick for me.

@rahul.sapkal23 2017-08-08 08:17:41

Solution --> npm start then open new Terminal and go to your project path and then hit react-native run-ios it works for me

@a_rahmanshah 2017-08-05 18:26:11

Closing the currently running React Packager terminal window, and then re-running your iOS project from Xcode should work.

@Syed 2017-07-23 17:03:02

Assuming that you are using nvm and multiple versions of node installed, here is the solution:

  1. Say that you run npm install -g react-native-cli in node v6.9.5.
  2. Now make node v6.9.5 as default by running nvm alias default 6.9.5
  3. Now run react-native run-ios

The problem is, you have multiple versions of node installed via nvm and to install react-native-cli you have switched or installed latest version of node, which is not marked as default node to point in nvm yet. When you run react-native run-ios this opens up another new terminal window in which default nvm is not pointed to the node version where you have installed react-native-cli. Just follow the above setup, I hope that should help.

@sonlexqt 2017-04-20 22:03:56

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 at YOUR_PROJECT/ios/build/. After this you should be able to run your app through react-native run-ios again. Hope this helps.

@l3aronsansgland 2017-07-21 21:23:02

What solved it for me:

  • Open a terminal window
  • cd into YOUR_PROJECT/ios
  • Remove the build folder with rm -r build
  • Run react-native run-ios again

Alternatively, you could open Finder, navigate to YOUR_PROJECT/ios and delete the build folder.

Then run react-native run-ios again.

Source: Andrew Bancroft

Related Questions

Sponsored Content

25 Answered Questions

[SOLVED] What is the difference between React Native and React?

33 Answered Questions

[SOLVED] React-router urls don't work when refreshing or writing manually

5 Answered Questions

12 Answered Questions

[SOLVED] Error Running React Native App From Terminal (iOS)

22 Answered Questions

[SOLVED] Android failed to load JS bundle

4 Answered Questions

[SOLVED] What is the difference between Hot Reloading and Live Reloading in React Native?

2 Answered Questions

[SOLVED] No bundle URL present in custom React Native project

6 Answered Questions

[SOLVED] No bundle URL present (react native)

  • 2017-05-13 05:36:24
  • joey
  • 6527 View
  • 12 Score
  • 6 Answer
  • Tags:   react-native

11 Answered Questions

[SOLVED] react native ios no bundle URL present issue

1 Answered Questions

[SOLVED] React-native no bundle URL present on getting started project

Sponsored Content