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


当前回答

执行如下命令:

killall -9 node
rm -rf ios/build
react-native run-ios

它将打开launchpacker .command,应用程序将安装在ios模拟器上

其他回答

我也遇到了这个问题(第一次开始使用React Native)。当一个ios模拟(react-native run-ios)正在运行时,问题消失了。我运行npm install,然后再次运行react-native run-ios。在终端窗口中,它显示正在捆绑,然后模拟器显示欢迎屏幕。

在react-native init PropertyFinder行之后检查这个链接,尝试使用npm start(这对我来说是有效的)

========================================================================

16.9更新

我的端口8081被McAfee阻塞。直接使用不同的端口不能工作react-native start——port=8082和react-native run-ios——port=8082

几乎所有的解都试过了。但是什么都不管用。

        "react": "16.9.0",
        "react-dom": "^16.12.0",
        "react-native": "0.61.5",

解决方案:

在Xcode中搜索8081,并将它们全部替换为8082。然后运行相同的命令来构建和运行应用程序。应用程序运行顺畅

react-native start --port=8082
react-native run-ios --port=8082

我是这样做的:

打开终端窗口 cd到YOUR_PROJECT/ios 使用rm -r build删除build文件夹 再次运行react-native Run -ios

我也遇到了同样的问题,我通过在AppDelegate中进行更改来解决它。m文件。我改变了

jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];

to

jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];

这对我来说很有效:)

我们通过删除构建脚本中的SKIP_BUNDLING选项来解决这个问题,RN文档建议添加该选项来加快调试构建。真正的修复(为了我们的原因)包含在RN 0.57中:

https://github.com/facebook/react-native/issues/20553

步骤1: 在xcode中打开。xcodeworkspace项目,通过“Terminal”导航, “开放/ ios /。xcodeworkspace"按Enter键。

步骤2: 删除主机。Jsbundle文件

步骤3: 回到VS Code,输入这个, React-native bundle——entry-file index.js——platform ios——dev false——bundle-output ios/main。Jsbundle——assets-dest ios

这将生成新的主线。jsbundle文件。

步骤4: react-native run-ios

你不会再次看到错误