React Native 踩坑: UnableToResolve
2018-07-18 本文已影响37人
河的左岸
使用React Native 开发,安装npm依赖必不可少,但是前几日开发中,却在这个环节栽了跟头,被卡住了几个小时。
问题
Metro Bundler ready.
Loading dependency graph, done.
error: bundling failed: Error: Unable to resolve module `AccessibilityInfo` from `D:\Workspace\Kart\app\node_modules\react-native\Libraries\react-native\react-native-implementation.js`: Module `AccessibilityInfo` does not exist in the Haste 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 -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`. 4. Remove haste cache: `rm -rf /tmp/haste-map-react-native-packager-*`.
at ModuleResolver.resolveDependency (D:\Workspace\Kart\app\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:167:1306)
at ResolutionRequest.resolveDependency (D:\Workspace\Kart\app\node_modules\metro\src\node-haste\DependencyGraph\ResolutionRequest.js:80:16)
at DependencyGraph.resolveDependency (D:\Workspace\Kart\app\node_modules\metro\src\node-haste\DependencyGraph.js:237:485)
at Object.resolve (D:\Workspace\Kart\app\node_modules\metro\src\lib\transformHelpers.js:116:25)
at dependencies.map.result (D:\Workspace\Kart\app\node_modules\metro\src\DeltaBundler\traverseDependencies.js:298:29)
at Array.map (<anonymous>)
at resolveDependencies (D:\Workspace\Kart\app\node_modules\metro\src\DeltaBundler\traverseDependencies.js:294:16)
at D:\Workspace\Kart\app\node_modules\metro\src\DeltaBundler\traverseDependencies.js:159:33
at Generator.next (<anonymous>)
at step (D:\Workspace\Kart\app\node_modules\metro\src\DeltaBundler\traverseDependencies.js:239:307)
BUNDLE [android, dev] ..\..\../index.js ░░░░░░░░░░░░░░░░ 0.0% (0/1), failed.
目前的版本:
D:\Workspace\Kart\app> react-native -v
react-native-cli: 2.0.1
react-native: 0.56.0
最后查到官网,原来这个版本根本就是有问题的:
Thanks for reporting this. This is indeed a breaking change for plugins. In order to prevent having to override the hasteImplModulePath configuration in end-user code, we're going to add an exception for react-native-windows in react-native. I'm working in a fix right now.
Meanwhile, we're going to work in a long-term solution for overriding core components from plugins, as the current approach is pretty hacky.