44

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?

Community
  • 1
  • 1
jjjjjjjj
  • 4,203
  • 11
  • 53
  • 72
  • 1
    after reading your question i don't know in which page are you in however the simplest way might have been to run the server by react-native start command... – Codesingh May 13 '17 at 06:35
  • 1
    Possible duplicate of [What means of no bundle URL present in react-native?](https://stackoverflow.com/questions/42610070/what-means-of-no-bundle-url-present-in-react-native) – Syed Jul 24 '17 at 15:48

20 Answers20

22

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

goksel
  • 4,450
  • 3
  • 42
  • 51
  • 1
    Then we need to move to the project and use the react-native run-ios command. Thanks it worked for me. – Chandni Jul 24 '18 at 13:38
  • The build dir doesn't exist for me - I guess it is cleaned up ??? I am just using the `expo` solution to run on my actual iPhone device (and not simulator) as per https://reactnative.dev/docs/environment-setup – HankCa Nov 23 '20 at 03:17
  • I also don't have the build dir @HankCa, were you able to find the solution? – Andrey Solera Aug 17 '21 at 19:25
  • No, I paused work in React Native. I will start up again soon. First I'd read https://www.newline.co/fullstack-react-native/ (I've no affiliation except I like the newline.io books and business model). They've also an article - https://www.newline.co/@kchan/building-macos-applications-with-react-native-for-macos--7fd38809 and I'm not sure if that is from the book. Heaps of other resources I'd follow including https://blog.crowdbotics.com/the-state-of-react-native-for-windows-macos-2021/. The toughest part of this tech is a need to have understanding of the native platform aswell as React. – HankCa Aug 19 '21 at 00:58
12

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

Saif Siddiqui
  • 856
  • 1
  • 13
  • 33
12

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.

Matt Booth
  • 1,723
  • 3
  • 13
  • 19
Hussam Kurd
  • 8,066
  • 2
  • 43
  • 38
8

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
Daniel Twork
  • 89
  • 1
  • 5
7

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.

Answered the same here: https://stackoverflow.com/a/45267703/1292050

Syed
  • 15,657
  • 13
  • 120
  • 154
  • 1
    This solved mine because a diff node version was default, and the run-ios command pops a new terminal window which defaulted to a super old node version. Thanks for the tip! – Troy Anderson Jul 07 '18 at 02:29
4

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 ;)

3

faced similar issue while running in real device app was getting crash after uploading to testflight upload and install folks this issue is killer

saved by this link https://onexlab-io.medium.com/no-bundle-url-present-fixed-ca2688a80f66

  • 1
    Hello and welcome to stack overflow. Instead of just linking to a webpage which answers the question, please take your time to provide an answer here and support it with a citation to the linked article. – Ente Sep 17 '21 at 12:52
2

I solved this problem by running npx react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios command on the app's root terminal.

If a file called main.jsbundle is created inside your ios folder, then rebuild the app. Else, it is likely that you got some output like

info Writing bundle output to:, ios/main.jsbundle
info Done writing bundle output
info Copying 61 asset files
warn Assets destination folder is not set, skipping...

If so go to XCode >> {Your App} >> {Your App Target} >> Build Phases >> Bundle React Native code and images and replace the node in export NODE_BINARY=node with the output of which node command executed on a different terminal.

Update RN Bundle node path

Then re-run npx react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios and generate the main.jsbundle file.

Then add the file to your app by right clicking XCode >> {Your App} and selecting the Add files to "{Your App Name}" option. Then select the newly created main.jsbundle file. Check if the file is added to XCode >> {Your App} >> {Your App Target} Build Phases >> Copy Bundle Resources

If the file is there, rebuild the app.

Manil Malla
  • 133
  • 8
1

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

Goker Ge
  • 27
  • 5
1

The below solved the same problem i had

brew update

brew reinstall watchman

0

I had the same issue happen to me not too long ago. It appears that if you renamed the project to something else and the project folder itself was renamed, you need to make sure you replace all instances of the old name with the new name and do not forget to change file names of your .xcscheme in ProjectName > ios > ProjectName.xcodeproj > xcshareddata > xcschemes. I also had to remove the build directory. Hope this works for you as well!

Eidan
  • 11
  • 4
0

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.

Mert Üner
  • 11
  • 2
0

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.

0

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

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 15 '22 at 15:44
  • when i did some changes on /etc/hosts i've got this error. this solution fix my problem too +1 – Nadav Avisror May 17 '23 at 18:33
0

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.

NAVNEET CHANDAN
  • 268
  • 3
  • 7
0
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.

Shay Elbaz
  • 39
  • 3
  • Hey, it's not clear if the needed is to run the command, clear project, run in Xcode or clear project then run the provided command in Xcode – Abderrahmen Hanafi Apr 04 '22 at 13:46
0

This relates to the answers from @Daria Kozlova and @Daniel Twork

I needed to have the server running in another tab, i.e. yarn start

But what I hadn't noticed is that the server had crashed with an error like:

jest-haste-map: Watchman crawl failed. Retrying once with node crawler.
  Usually this happens when watchman isn't running. Create an empty `.watchmanconfig` file in your project's root folder or initialize a git or hg repository in your project.
  Error: Watchman error: std::__1::system_error: open: /Users/anentropic/Documents/Dev/Work/myproject/mobile-app: Operation not permitted. Make sure watchman is running for this project. See https://facebook.github.io/watchman/docs/troubleshooting.

...

  watchmanResponse: {
    error: 'std::__1::system_error: open: /Users/anentropic/Documents/Dev/Work/myproject/mobile-app: Operation not permitted',
    version: '2022.09.12.00'
  }

The fix for that can be found here:
https://github.com/facebook/watchman/issues/977#issuecomment-1189903929

i.e. run:

watchman watch-del-all
watchman shutdown-server

and then yarn start again

react-native run-ios works now

Anentropic
  • 32,188
  • 12
  • 99
  • 147
0

just try,

  • npm start
  • npm react-native run-ios
Manoj Alwis
  • 1,337
  • 11
  • 24
0

In the package.json add the following in the script section,

"bundle:ios": "react-native bundle --entry-file='index.js' --bundle-output='./ios/main.jsbundle' --dev=false --platform='ios'"

The quotes around file name and platform value is a must.

In the pipeline execute

yarn bundle:ios

before archiving. That's it, updated main.jsbundle will get added to the package. If your project path is different then slight change in path might be required.

ibiren
  • 673
  • 6
  • 25
-1

There must be built issues in your app. Try building with Xcode or terminal