react错误总结

react-native 错误总结

The development server returned response error code: 500 in react-native

https://blog.csdn.net/qingsong_xu/article/details/72515075

这里写图片描述

写ReactNative应用时遇到:The development server returned response error code: 500,经查看是由于某个modules不在modules map里,多次关闭terminal及模拟器均未解决,最后根据错误提示,三行代码解决。
按顺序在命令行里执行一下下面的指令,运行过程中未报错,基本就ok了,嘿嘿
1、watchman watch-del-all
2、rm -rf node_modules && npm install
3、rm -fr $TMPDIR/react-*

若还是未能解决,则应该仔细看看错误提示是什么了。
这里写图片描述

我的提示是Moduel does not exist in module map or in these direactories.
说白了就是找不到module,然而我的确是import了这个module,最后仔细查看了目录结构:
这里写图片描述

我是从index.android.js中默认首页为FirstPage。在index.android.js的相对路径是‘./pages/FirstPage’
这里写图片描述

在index.android.js importe FirstPage时,必须是相对路径,才能成功!!绝对路径还是会报同样的错!有点小坑

另外,练习Navigator时,必须安装一下“过时的自定义组件”,否则无法正常使用。

npm install --save react-native-deprecated-custom-components
原文地址:https://www.cnblogs.com/xiaocongcong888/p/9363934.html