react-native使用填坑记录

1 react-native 在新版Xcode(10+)中运行出现的问题:

 node_modules/react-native/third-party/glog-0.3.5 , C compiler cannot create executables

third-party: 'config.h' file not found 解决方案

错误截图


错误截图


这个是常见错误,只需要在项目根目录下运行以下命令即可解决:

 cd node_modules/react-native/third-party/glog-0.3.5

 ../../scripts/ios-configure-glog.sh 


参考github 问题地址  https://github.com/facebook/react-native/issues/19774


2 react-native 在新版Xcode(10+)中运行出现的问题:bundling failed: Error: Unable to resolve module /../react-transform-hmr/lib/index.js 


错误截图

用 react-native start --reset-cache命令解决了

参考github 问题地址:https://github.com/facebook/react-native/issues/21530

参考 https://segmentfault.com/a/1190000016601700


3 When starting a new project with react-native init then run iOS, I'm getting the error :

Module @babel/runtime/helpers/interopRequireDefault does not exist in the Haste module map


错误截图


解决方案截图

for now after react-native init, since a lot of new changes are coming out, this fix worked for me (I got it from reading other issues):

with npm:

npm install --save-dev @babel/core

npm install --save-dev @babel/runtime

npm run start --reset-cache

or

react-native start --reset-cache

参考:https://github.com/facebook/react-native/issues/21310


4 typeerror cannot convert undefined or null to object

错误截图

调试看日志,一般情况就是网络返回数据字典无法转成对象,

我在定义了一个对象RowData,而网络请求返回的是字典需要将字典转换成对象就可以了。


cell里面定义是对象


请求数据截图

需要将网络请求返回的数据转为成对象就ok了。



5 Module AppRegistry is not registered callable module (calling runApplication)


错误截图

解决方案

Just kill all node process and start npm server and run application:

Step1: run command killall -9 node

Step2: run command npm start

Step3: run command react-native run-ios OR react-native run-android



6 用第3方库react-native-scrollable-tab-view报的错误

错误截图

解决方案删掉第9行props后面的逗号就行了或者运行作者fix bug的代码也可以


解决方案截图


解决方案截图

npm i -s https://github.com/happypancake/react-native-scrollable-tab-view.git to get fix code from master



7 用第3方库react-native-viewpager报的错误

undefined is note an object(evaluating 'React.propTypes.func') 


错误截图


解决方案截图



8 Module not found:Can't resolve '@babel/runtime/helpers/builtin/** in '...'


错误提示截图


解决方案截图

参考:https://zj-john.github.io/tips/cjkwcx8ex009jakf0pd95ekzv.html        



9 eslint@5.6.0: The engine "node" is incompatible with this module. Expected version "^6.14.0 || ^8.10.0 || >=9.10.0" 


错误提示截图
解决方案截图

上面的翻译如下:

1 在终端执行npm install npm@latest -g 

2 然后去js官网下载最新的版本安装

https://nodejs.org/zh-cn/


下载最新的js版本并安装

3 然后在执行在指定文件夹,打开terminal终端用命令create-react-app todomyapp就不报错误了。


最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • This project was bootstrapped with Create React App. Belo...
    unspecx阅读 10,599评论 0 2
  • afinalAfinal是一个android的ioc,orm框架 https://github.com/yangf...
    wgl0419阅读 11,512评论 1 9
  • 2016-12-10 小芳原创 小芳的天空 好朋友在朋友圈里发了一点感悟,觉得人的成长与成熟和时...
    小芳的天空阅读 3,535评论 0 1
  • 3.15是消费者权益日,也是一季的供暖季结束的日子,乍暖还寒的北方,风还带着丝丝凉意,没有暖气的烘托,在屋里呆着还...
    斐之然阅读 4,110评论 0 0
  • “在美妙无比的草地上,有座金色的房子,一个孩子住在里面。草地周围是金色的围墙,墙上有个很小很小的洞。孩子喜欢从洞里...
    锦鲤座lemon阅读 2,910评论 0 0

友情链接更多精彩内容