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


当前回答

这是因为你可能已经关闭了地铁捆绑窗口,或者它可能崩溃了。只需在项目目录下打开另一个终端/cmd并运行NPM start。通过运行npm start React Native将再次启动MetroBundler窗口。在捆绑器完成BUNDLE过程后,只需重新加载应用程序,您就可以开始了。

其他回答

这是react-native v0.42.1的一个问题。尝试关闭所有终端和XCode实例并运行:

launchctl unload ~/Library/LaunchAgents/com.github.facebook.watchman.plist
watchman version
react-native run-ios

对于我的用例,我必须删除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

大多数情况下,此问题发生在DNS查找/ IP查找无法找到本地主机时。

解决方案:

尝试将localhost ip添加到etc主机文件中。

你可以在etc主机文件(/etc/hosts)中添加以下代码行

127.0.0.1 localhost

255.255.255.255 广播主机

::1升。ocalhost

要确认这就是问题所在 你可以在safari上点击bundle url(如果你在chrome中尝试,这将解决,但safari将无法解决它)。http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false

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

react-native upgrade

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

另一件对我有用的事情是,在xcode中打开项目,然后清理并构建它。通常它会重新运行打包服务器并解决问题。