What is the meaning of 'No bundle URL present' in react-native?

前端 未结 30 2126
庸人自扰
庸人自扰 2020-11-30 17:22

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.

相关标签:
30条回答
  • 2020-11-30 17:40

    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

    0 讨论(0)
  • 2020-11-30 17:43

    Try running this code:

    $ sudo xcodebuild -license

    This may fix the issue. This works for me.

    0 讨论(0)
  • 2020-11-30 17:43

    It has happened to me as well, after restarting my mac. There's a launchPackager terminal window opening up when you run your app on the simulator. I closed that window and terminated the process (I also cloosed the simulator), then run again react-native run-ios and everything works fine.

    0 讨论(0)
  • 2020-11-30 17:44

    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>
    
    0 讨论(0)
  • 2020-11-30 17:44

    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.

    0 讨论(0)
  • 2020-11-30 17:45

    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.

    0 讨论(0)
提交回复
热议问题