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


当前回答

好吧,这听起来可能很奇怪,但这些答案对我都没用。 我现在在react-native 0.60,问题发生在ios和android上。 对我来说唯一有效的解决办法就是跑步 React-native run-ios或React-native run-android 然后,当出现错误时,运行 npm install(保持捆绑器和模拟器打开) 然后运行react-native run-ios或react-native run-android

其他回答

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

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。

如果像我一样,您有一个在终端会话(.bashrc/.bash_profile)启动时执行的命令集,它等待输入(在我的例子中,是SSH Key的密码短语,带SSH -add),那么您将注意到它实际上阻止打开的终端启动Metro服务器!

尝试在启动时禁用该命令(或者至少在React Native打开的终端中禁用)。这对我很管用!

以下步骤:

用xcode打开ios文件项目 在项目包中删除main。jsbundle文件 通过main添加新的空文件。jsbundle名字 运行comment: react-native bundle——entry-file index.js——platform ios——dev false——bundle-output ios/main。Jsbundle——assets-dest ios 现在是react-native run-ios

youtube链接:https://www.youtube.com/watch?v=eCs2GsWNkoo

也许你忘了这一步

cd ios && pod install

好吧,这听起来可能很奇怪,但这些答案对我都没用。 我现在在react-native 0.60,问题发生在ios和android上。 对我来说唯一有效的解决办法就是跑步 React-native run-ios或React-native run-android 然后,当出现错误时,运行 npm install(保持捆绑器和模拟器打开) 然后运行react-native run-ios或react-native run-android