ReactNative红屏: Unable to resolve module 和 Error: Plugin

Unable to resolve module AccessibilityInfo from XXX

android启动后大红屏错误, 具体信息是这个

Unable to resolve module `AccessibilityInfo` from `xxx\node_modules\react-native\Libraries\
react-native\react-native-implementation.js`: Module does not exist in the module mapThis might be related to https://github.com/facebook/react-native/issues/4968To resolve try the following:  1. Clear watchman watches: `watchman watch-del-all`.
  2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
  3. Reset Metro Bundler cache: `rm -rf $TMPDIR/react-*` or `npm start -- --reset-cache`.  
  4. Remove haste cache: `rm -rf $TMPDIR/haste-map-react-native-packager-*`.12345678910

现在安装的是最新的ReactNative(现在是0.56), 这个问题可能是新版本的bug, 降级到0.55即可.

降级流程: 
1. 在工程目录下执行 E:\ReactNative\Test>npm install --save react-native@0.55.4
2. 然后 E:\ReactNative\Test>react-native upgrade, 这里会提示你要不要覆盖原来的部分文件, 我是一路y, 最后提示 Successfully upgraded this project to react-native v0.55.4
3. 接下来再运行, 提示一个android目录下build错误, 我猜应该是build旧文件的错误, 所以删掉了android目录下的几个build文件夹; 
4. 又有问题( 如果没有这么多问题就跳过这些步骤 ): MainApplication 内找不到 BuildConfig ,代码问题好办, 用AS打开, import BuildConfig 就可以了.

另外, Unable to resolve module react-navigation from 可以用 npm install react-navigation@https://github.com/react-community/react-navigation.git --save 解决.

至此, mission complete, 来到下一个问题(手动滑稽)


Module build failed: Error: Plugin 0 specified in “base” … provided an invalid property of “default”

也是个大红屏错误, 是在babel-preset-react-native包里的文件错误, 看了下那个文件, 没有几行代码.

最后在 https://github.com/facebook/react-native/issues/15545 的回答中找到适合我的方法.

执行 npm install --save-dev babel-preset-react-native@2.1.0 后再次运行即可, 终于看到梦寐以求的界面了

这里写图片描述

原文: https://blog.csdn.net/j550341130/article/details/81027700

推荐您阅读更多有关于“”的文章

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值