React Native错误收集汇总 - xw332/xw332.github.io GitHub Wiki
官方的通用方案,除了代码的问题,先跑下总没错
初步清理:watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf $TMPDIR/metro-bundler-cache-* && rm -rf $TMPDIR/haste-map-react-native-packager-*
深度清理:rm -rf $TMPDIR/react-* && npm cache clean --force && react-native start --reset-cache
最后尝试:重启终端/重启模拟器/重启Xcode/重启电脑
https://www.jianshu.com/p/2055696a182c
https://blog.csdn.net/zwkkkk1/article/details/95589414
https://stackoverflow.com/questions/46878638/how-to-clear-react-native-cache/52383821#52383821
问题(常见度4星):react-native run-ios 之后模拟器启动了,但是项目没运行
解决:需要手动react-native start,启动项目
问题(常见度4星):Could not find iPhone X simulator
解决:https://www.cnblogs.com/lude1994/p/11076196.html
https://www.cnblogs.com/gdsblog/archive/2019/12/15/12042103.html
问题(常见度4星):unknown argument type '__attibute__'
解决:https://blog.csdn.net/askme_/article/details/101206086
https://blog.csdn.net/lizhijian21/article/details/101367768
低版本RN在新版本Xcode下会有这个问题
问题:Xcode编译的时候进度条卡住,也不报错
解决:https://www.cnblogs.com/richard-youth/p/9718892.html
很可能是下载第三方依赖时,下载速度太慢所以卡住,也不报错
第三方依赖库百度盘链接:http://pan.baidu.com/s/1kVDUAZ9
问题:Cannot read property 'bind' of undefined 或 undefined is not an object evaluating _this._setComponentRef.bind 或 Cannot read property 'bindings' of null
解决:https://github.com/facebook/react-native/issues/20588
和babel配置有关,比如@babel/plugin-transform-flow-strip-types或@babel/plugin-proposal-class-properties
问题(常见度3星,排查耗时5星):Can't find variable: require
解决:https://github.com/facebook/react-native/issues/21048#issuecomment-479836224
https://github.com/facebook/react-native/issues/3379
大部分情况是babel配置导致的,目前测试下来,@babel/plugin-transform-runtime不能和module:metro-react-native-babel-preset一起使用。
还有一种情况是缓存导致的,用react-native start --reset-cache可以解决。如果缓存还在,并且导致所有其他项目都不能运行,尝试删掉babel配置文件进行编译然后报错,能触发缓存清除的机制,再把babel配置文件放回来尝试正常运行。
问题:.overrides is not allowed in preset options
解决:https://stackoverflow.com/questions/51668553/babel-preset-react-native-and-higher-order-components
和babel版本有关
问题:PropTypes.number 报错
解决:https://www.jianshu.com/p/73bb6f75ed31
PropTypes必须要用static声明,否则报错
问题:Unexpected trailing comma after rest element
解决:https://www.jianshu.com/p/49718bbebc7b
问题(常见度4星):react-native No bundle URL present
解决:https://blog.csdn.net/c_kite/article/details/79215023
问题(常见度2星,排查耗时4星):mergeFast.js文件找不到
解决:https://github.com/facebook/react-native/blob/0.55-stable/Libraries/Utilities/mergeFast.js
0.56已经删掉了这个文件,部分三方库如react-native-text-gradient需要升级
问题(常见度4星):Module crypto
does not exist in the Haste module map
解决:https://www.jianshu.com/p/dee734041a90
使用react-native-crypto或crypto-js代替
如果是其他依赖包,可以再单独安装一次来运行
问题:undefined is not an object (evaluating 'RNRandomBytes.seed'
解决:https://www.npmjs.com/package/react-native-randombytes
react-native-randombytes命令行link失败,可以手动link修复
问题(常见度4星):No bundle URL present Make sure you’re running a packager server or have included a .jsbundle file
解决:https://www.jianshu.com/p/4fc74ebf7865
通常是上一个项目的进程未关闭
问题(常见度4星):"xxx module " does not exisg in the haste module map
解决:分缓存和写错代码引用,缓存就重启终端,写错引用就检查是否写了正确的相对路径
问题:could not obtain pthread_key
解决:未解决,目前出现在老项目不支持Xcode11,运行中断
问题:could not launch simulator for iphonesimulator
解决:https://stackoverflow.com/questions/29296360/ios-simulator-is-not-launching
删除模拟器或者重新下载Xcode
问题:no such file or directory XXXX文件找不到
解决:有一种可能是同时有多个项目的bash窗口,全部关掉之后,再重新编译
在build phases => complie sources 下面找到文件删了 重新编译
问题(常见度2星):Cannot read property 'match' of undefined
解决:好像是npm工具坏了,需要每次删除package.lock.json
问题(常见度4星):UIManager.getViewManagerConfig is not a function
解决:使用低版本插件如6.11.1的webview,或者升级RN版本到0.58以上,或者修改插件源码
UIManager.getViewManagerConfig在0.58之后加入,一些组件在0.58之前的RN版本下会报错
问题(常见度4星):Undefined symbols for architecture x86_64: "_JSClassCreate"
解决:"Link Binary With Libraries" 里加入 JavaScriptCore.framework
和ios12的系统版本有关
问题:pod install提示:bad interpreter: No such file or directory信息
解决:https://www.jianshu.com/p/99aae0af1c6c
和Mac系统升级有关
问题:iOS Pod 'xxx.h' file not found with include; use "quotes" instead
解决:https://blog.csdn.net/xjh093/article/details/93477302
问题:安卓react-native-view-shot在 RN 0.56/0.57 的 ScrollView 下截图黑屏
解决:https://github.com/gre/react-native-view-shot/issues/179
问题:安卓react-native-render-html在 RN 0.57 的 ScrollView 下滚动冲突,概率出现反向滚动
解决:
问题:com.facebook.react.bridge.NoSuchKeyException: lineNumber
解决:https://github.com/facebook/react-native/issues/24382
RN捕获的异常不显示具体内容,和stacktrace-parser的新版更新有关,回退到0.1.4
问题:两个scrollviews之间有很多空间,因为换行
解决:https://cloud.tencent.com/developer/ask/213245
问题:npm install报错类似于npm WARN tar ENOENT: no such file or directory, open '*\node_modules.staging*
解决:https://www.cnblogs.com/eyelly/p/npm_error_staging.html
问题:在部分手机上Text尾部显示不全,例如Pixel、魅族等手机
解决:https://www.jianshu.com/p/30fd302d028a
扩展链接:
https://blog.csdn.net/u010127332/article/details/83622209
http://www.chengxiangqian.com/?p=1357
https://www.jianshu.com/p/c9bbb8c9ed32
https://www.wandouip.com/t5i147163/
打包安卓碰到的问题
问题:echarts图表不显示
解决:https://blog.csdn.net/zzqwxx/article/details/80856738
问题:build.gradle 引用三方库报错 maven { url '$rootDir/../node_modules/react-native/android'}
解决:把单引号换成双引号
打包ios碰到的问题
问题:xcpretty: command not found
解决:https://github.com/xcpretty/xcpretty
安装命令:gem install xcpretty