开发项目时,遇到下面的报错。
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 提供的东西,没有找到启动的代码,所以报这个错误。代理打开了果然就好用了?