React Native App-开发服务器返回响应错误代码:500

时间:2018-09-21 20:46:23

标签: android react-native genymotion

我再次询问是因为我的案子在以前的回答中并未解决。 我创建了一个可以在Snack上完美运行的React Native App,但是后来我想在Expo上尝试一下(我想添加一些Snack无法加载的模块)。 因此,我使用create-react-native-app来制作项目。 然后,在编辑代码之后,我尝试使用Genymotion模拟器启动它,但是每次执行此操作时,都会发生以下错误: enter image description here

我不明白这是怎么回事? 我已经尝试删除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

我该怎么办?请帮助我。

反应本机版本:0.55.2

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

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

2 个答案:

答案 0 :(得分:0)

该应用程序正在您自己的应用程序文件夹中查找./components/AssetExample。

答案 1 :(得分:0)

Please give us your project structure and the code in App.js file (also make sure you export AssetExample class in AssetExample.js file.
What i understand you are trying to do is (probably) that in App.js you import AssetExample from "./components/AssetExample", so possible errors are:
1) path is wrong
2) you don't export default AssetExample in AssetExample.js