首页 > 解决方案 > React Native App - 开发服务器返回响应错误代码:500

问题描述

我再问一次,因为我的案子没有根据以前的答案解决。我创建了一个在 Snack 上完美运行的 React Native App,但后来我想在 Expo 上尝试一下(我想添加一些 Snack 无法加载的模块)。所以,我曾经create-react-native-app制作我的项目。然后,在编辑代码后,我尝试使用 Genymotion 模拟器启动它,但每次我这样做时,都会出现以下错误: 在此处输入图像描述

我无法理解它有什么问题?我已经尝试删除 node_modules 文件夹,更改 React Native 和 Babel 版本并使用npm install. 此外,在控制台中,它向我显示了这个错误:

22:33:56: Unable to resolve ./components/AssetExample" from "./C:\\Users\\danie\\HC\\App.js`: The module `./components/AssetExample` could not be found"
22:33:56: Failed building JavaScript bundle

但我不知道这个模块应该在哪里导入?package.json 还是 package-lock.json?

我使用以下命令在 Genymotion 中启动它:

cd HC
npm start android

我能做些什么?请帮我。

React Native 版本:0.55.2

Babel(预设 React Native) 版本:^4.0.0

编辑:项目结构和代码按要求,我在 GitHub 上创建了存储库:https ://github.com/DanielVip3/HC ^ 我没有推送 node_modules 文件夹,因为它太大了,但我想你已经知道了:它包含 React Native 使用的所有模块。

标签: androidreact-nativegenymotion

解决方案


请给我们您的项目结构和 App.js 文件中的代码(同时确保您在 AssetExample.js 文件中导出 AssetExample 类。
我了解您正在尝试做的是(可能)在 App.js 中您从“./components/AssetExample”导入 AssetExample,因此可能的错误是:
1)路径错误
2)您没有在 AssetExample.js 中导出默认 AssetExample

推荐阅读