当我运行一个react-native项目时,我得到一个错误,没有bundle URL,但我不知道我做了什么错误,我很困惑。


当前回答

对于我的用例,我必须删除node_modules目录并运行npm install。

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

如果你得到错误“dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.58。Dylib”,执行以下操作:

$ 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

其他回答

我尝试了下面所有的解决方案,但都不起作用:

Sudo xcodebuild -license或 使用rm -r build删除build文件夹并运行react-native run-ios或 NPM启动并运行react-native run-ios 添加NSAppTransportSecurity到localhost

我是这样解决的:

打开主机文件sudo vi /private/etc/hosts(如果你使用VSCode,使用这个sudo code /private/etc/hosts) 如果不存在,添加三行

127.0.0.1 localhost
255.255.255.255 localhost
::1 localhost

再次运行react-native Run -ios。

当您不允许通过localhost进行不安全连接时,或者您试图通过http接受不安全连接时,就会发生此问题。

要解决这个问题,在info.plist上添加这个:

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

关闭模拟器和终端。打开一个新的并进入你的项目,然后像这样升级你的react-native:

react-native upgrade

问题:当bundle执行失败时,RCTFatal中的无限递归。

对我来说,问题是它不能创建JS包。当从Xcode构建时,它没有声明错误,所以你无法知道这一点。要查找错误,请运行以下命令。

React-native bundle——platform ios——dev false——entry-file index.ios.js——bundle-output ./ios/release/mainJsbundle——assets-dest ./ios/release/main.jsbundle

对我来说,错误是缺少PureRenderMixin组件。解决方案可以在这里找到:https://github.com/facebook/react-native/issues/13078。基本上你必须手动安装react@16.0.0-alpha.3。这可以通过运行这个命令来完成。

NPM I——保存react@16.0.0-alpha.3

现在每个人都遇到了这个问题,因为新版本的react alpha正在发布(特别是alpha.5),它们破坏了react原生构建。

对于我的用例,我必须删除node_modules目录并运行npm install。

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

如果你得到错误“dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.58。Dylib”,执行以下操作:

$ 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