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


当前回答

我在我的macbook上通过电缆和wifi连接到网络,关闭wifi,点击运行,它就工作了!

其他回答

以下步骤:

用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

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

我也遇到过这样的问题……问题是封装器没有运行,似乎可能是因为我的默认shell是zsh。react-native厌倦打开一个新的终端窗口并运行…/node_modules/react-native/packager/ launchpacker .命令,但是这个命令没有运行。手动运行(并保持运行)为我解决了这个问题。

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

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

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。