react-native - 在任何根目录中都找不到入口文件 index.android.js :[ Android ]

标签 react-native

我正在尝试使用 Windows 7 和 Android 设备使用 React Native 启动我的 hello world 应用程序。还有类似的问题here但我没能成功。

到目前为止我运行的命令设置并导致了这个问题。

  1. 创建应用:react-native init helloMe
  2. 移至根目录 [helloMe]。 react-native run-android
  3. Android 设备设置正常并使用 adb 在 CMD 中显示
  4. 打开另一个 CMD 窗口然后运行:react-native start
  5. 再次运行 react-native run-android
  6. 手机上显示红屏,此错误无法 load script from assets index.android.bundle on windows
  7. 尝试使用步骤 6 中的解决方案修复它会导致另一个错误,这就是我来这里的原因。下面是我的 CMD 日志。

    E:\testdir\react_ws\helloMe>react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
    Scanning 558 folders for symlinks in E:\testdir\react_ws\helloMe\node_modules (30ms)
    Scanning 558 folders for symlinks in E:\testdir\react_ws\helloMe\node_modules (20ms)
    Loading dependency graph, done.
    Cannot find entry file index.android.js in any of the roots: ["E:\\testdir\\react_ws\\helloMe"]
    E:\testdir\react_ws\helloMe>
    

现在,当我尝试使用上述解决方案解决问题时出现另一个错误。

Cannot find entry file index.android.js in any of the roots: ["E:\\testdir
\\react_ws\\helloMe"]

如果尝试应用来自 here 的此修复程序

npm run start -- --root <directory_with_your_react_component_js_sources>

因为我在项目根目录下运行命令,所以我改为运行这个 npm run start -- --root ./ 但它不起作用。

这是我的根项目结构

__tests__  app.json          index.ios.js  node_modules  yarn.lock
android    index.android.js  ios           package.json

我希望我清楚,任何帮助将不胜感激。设备卡在红色屏幕上并显示 404。

React-native-version

react-native-cli: 2.0.1
react-native: 0.46.0

谢谢。 Requested Project root Structure Snapshot

CMD NPM Start Sceenshot 2

最佳答案

将 React 项目的版本从 here 更改为较低版本

npm install -g rninit

rninit init [Project Name] --source react-native@0.40.0

在 .如果您得到 错误 Could not get BatchedBridge。运行这个

adb reverse tcp:8081 tcp:8081

这对我有用。

关于react-native - 在任何根目录中都找不到入口文件 index.android.js :[ Android ],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44944194/

相关文章:

ios - React-Native AsyncStorage.clear() 在 IOS 上失败

post - React Native axios总是返回 'Request failed with status code 400'

reactjs - react .createElement : type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got undefined

react-native - 在卡片中显示 webview( react native )

react-native - 当应用程序进入前台时,React Native 停止 WebView 重新加载

react-native - 弹出我的 expo react-native 应用程序时不会生成 index.js 文件

xcode - 为什么我会收到此错误 : 'import of module appears within namespace' on xcode with react-native?

css - 无法让对象从屏幕右侧开始

react-native - 我的屏幕名称未出现在 Firebase Analytics 仪表板中

javascript - React Native - 轮式选择器 : Invariant violation. 'WheelCurvedPicker' 的 native 组件不存在