解决 React Native 报错:Unable to resolve module `AccessibilityInfo`

开发项目时,遇到下面的报错。

UnableToResolveError: Unable to resolve module `AccessibilityInfo` from `XX/node_modules/react-native/Libraries/react-native/react-native-implementation.js`: Module does not exist in the module map

This might be related to https://github.com/facebook/react-native/issues/4968
To 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 -fr $TMPDIR/react-*` or `npm start -- --reset-cache`.
    at ModuleResolver.resolveNodeDependency (XX/node_modules/metro-bundler/src/node-haste/DependencyGraph/ModuleResolution.js:292:11)
    at ModuleResolution.tryResolveSync (XX/node_modules/metro-bundler/src/node-haste/DependencyGraph/ResolutionRequest.js:109:16)
    at Object.tryResolveSync (XX/node_modules/metro-bundler/src/node-haste/DependencyGraph/ModuleResolution.js:118:12)
    at ResolutionRequest.resolveDependency (XX/node_modules/metro-bundler/src/node-haste/DependencyGraph/ResolutionRequest.js:106:39)
    at dependencyNames.map.name (XX/node_modules/metro-bundler/src/node-haste/DependencyGraph/ResolutionRequest.js:140:10)
    at Array.map (<anonymous>)
    at ResolutionRequest.resolveModuleDependencies (XX/node_modules/metro-bundler/src/node-haste/DependencyGraph/ResolutionRequest.js:139:42)
    at Promise.resolve.then (XX/node_modules/metro-bundler/src/node-haste/DependencyGraph/ResolutionRequest.js:179:21)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

然而给出的提示并没有解决我的问题,试了好多次删除node_modules都不行。
后来发现问题出在代理上面,因为之前配置一个代理的时候,把代理全部关掉了,包括下面这俩货:

127.0.0.1	localhost
::1            localhost

然后跑RN的时候就是一直转圈,提示:

Connection to http://localhost:XX/debugger-proxy timed out. Are you running node proxy? If you are running on the device, check if you have the right IP address in RCTWebSocketExecutor.m

我没有管它,直接在浏览器里面访问了 http://localhost:3009/index.bundle ,就出现了最开始的AccessibilityInfo错误。
后来在同事的提醒下,先解决 time out 的问题。因为貌似 AccessibilityInfo 是 native 提供的东西,没有找到启动的代码,所以报这个错误。代理打开了果然就好用了?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值