【问题标题】:I get a running error with the idex bundle or metro what to do?使用 idex 捆绑包或 Metro 时出现运行错误该怎么办?
【发布时间】:2019-08-11 03:35:24
【问题描述】:

无法加载脚本。确保您正在运行 Metro 服务器(“运行 react-native start”)或您的捆绑包“index.android.bundle”已正确打包以供发布

【问题讨论】:

  • 请告诉我们您遇到的所有问题,例如导致此错误的代码、程序包、模块以及其他开发人员可以解决您问题的有用信息。
  • 发生此错误的原因有很多。
  • 它说无法解析模块'./index'。 Metro 没有获得索引,我无法在我的设备上运行。我正在使用 android studio 将我的手机与代码相关联
  • 你的 Metro 捆绑器还在运行吗?

标签: react-native


【解决方案1】:

我本可以将其发布为评论,但它需要很少的详细说明......

  • 我尝试在项目中添加资产文件夹 -> android/app/src/main/ 文件夹

  • 检查我的 index.js 是否正常并且所有条目都正常

import { AppRegistry } from "react-native";
import App from "./App";
import { name as appName } from "./app.json";  
AppRegistry.registerComponent(appName, () => App);
  • 运行此命令

react-native bundle --platform android --dev false --entry-file index.js --捆绑输出 android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

现在我可以运行该应用程序了。这一切我都试过搜索SO,参考问题是

1) stack overflow reference 1 2)Stack overflow reference 2

【讨论】:

    猜你喜欢
    • 2022-11-13
    • 1970-01-01
    • 2018-03-20
    • 1970-01-01
    • 1970-01-01
    • 2013-06-16
    • 1970-01-01
    • 2012-09-06
    • 2021-04-27
    相关资源
    最近更新 更多