No bundle URL present (react native)

Viewed 38782

Just installed react native and trying to get Hello World up and running. Been receiving this error for the last few hours:

 "No bundle URL present.Make sure you're running a packager server
 or have included a .jsbundle file in your application bundle."

I've referred to this: What means of no bundle URL present in react-native? and other similar questions, and tried everything: using my ip addresse, different combos of react-native run-iso and npm install while running and not running, tried deleting builds, cleaning project, restarting Xcode, simulator multiple times, tried react-native-upgrade, edited into.plist to allow arbitrary loads, manually setting the path to my index.ios.js, everything, and nothing works.

I noticed many ran into this issue when trying to build on their device. i'm not trying to do anything fancy, just get 'hello world' up and running.

Any other solutions I am not aware of?

14 Answers

cd into YOUR_PROJECT/ios and rm -r build, then run again react-native run-ios

I have the same issue, my problem was with info.plist I just config it as the following:

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

from this solution https://stackoverflow.com/a/48471978/1627358

And then add Bash config file .bashrc with this command:

echo "alias rni=\"kill \$(lsof -t -i:8081); rm -rf ios/build/; react-native run-ios\"" >> ~/.bashrc; source ~/.bashrc

Then run rni

from this solution https://stackoverflow.com/a/44080527/1627358

And it works fine with me.

run the following code:

killall -9 node
rm -rf ios/build
react-native run-ios

it will open launchpackager.command and the application will install on the ios simulator

The solution that worked for me.

You need to run:

yarn start

And at the same time (in a different terminal window):

yarn run:ios

I had this issue after I run the following commands to clean the project to see the changes which were invisible because of the cache and so on:

watchman watch-del-all
rm -rf node_modules && npm install
rm -rf /tmp/metro-bundler-cache-* or npm start -- -- reset-cache
rm -rf /tmp/haste-map-react-native-packager-*  

The reason for the issue was in the comment in dom-structure which didn't let the application run on the device. So, check the comments too ;)

The solution that worked for me.

> sudo vim /etc/hosts

add

 # Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1   localhost
255.255.255.255 broadcasthost
::1             localhost

then

> sudo killall -HUP mDNSResponder

the reason is I change hosts

I've run into this issue when I tried to sync my files to iCloud Drive. I have no idea what causes this, but as soon as I turn off my iCloud Drive and reinstall brew and Node, it started to work again. I can only think that when I turned on iCloud Drive, I might have ended up having two different Node versions or any other dependency.

To debug, your best first step is to scroll through the log text that outputs in the terminal window where you fired off "npx react-native run-ios" and search for the word like "error" or "failed". This will point you toward something more specific than the general "No bundle URL present" error.

For example, you might see something like "BUILD FAILED The following build commands failed: ProcessInfoPlistFile". In this example, I'd then know to go check on my Info.plist. You might see something different, but the debug methodology would still be the same.

If you are trying to run iOS, another idea is to build your app with Xcode itself by opening <YOUR_PROJECT_NAME>.xcworkspace with Xcode, then review its error messages.

Similarly, if you are trying to run Android, then try running with Android Studio and review its error messages.

Lots of answers are given, but one thing you should surely be taking care of while facing this issue is to

make sure that your Metro server is running.

npx react-native bundle --entry-file='index.js' --bundle-output='./ios/main.jsbundle' --dev=false --platform='ios' --assets-dest='./ios'

Try This, clear project, and run in xCode.

Edit /etc/hosts 127.0.0.1 localhost this is work for me !!!

Related