react-native错误:无法解析模块`AccessibilityInfo`
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了react-native错误:无法解析模块`AccessibilityInfo`相关的知识,希望对你有一定的参考价值。
我是React-native的新手我在尝试构建我的第一个应用程序时遵循了所有指令我遇到了这个错误。我有明确的捕获重启npm但仍然有这个错误。
The development server returned response error code: 500
URL: http://10.0.2.2:8081/index.delta?platform=android&dev=true&minify=false
Body:
{"originModulePath":"F:\React Native\AttendenceSystem\node_modules\react-native\Libraries\react-native\react-native-implementation.js","targetModuleName":"AccessibilityInfo","message":"Unable to resolve module `AccessibilityInfo` from `F:\React Native\AttendenceSystem\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-*`.","errors":[{"description":"Unable to resolve module `AccessibilityInfo` from `F:\React Native\AttendenceSystem\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-*`."}],"name":"Error","stack":"Error: Unable to resolve module `AccessibilityInfo` from `F:\React Native\AttendenceSystem\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 (F:\React Native\AttendenceSystem\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:167:1306)
at ResolutionRequest.resolveDependency (F:\React Native\AttendenceSystem\node_modules\metro\src\node-haste\DependencyGraph\ResolutionRequest.js:80:16)
at DependencyGraph.resolveDependency (F:\React Native\AttendenceSystem\node_modules\metro\src\node-haste\DependencyGraph.js:237:485)
at Object.resolve (F:\React Native\AttendenceSystem\node_modules\metro\src\lib\transformHelpers.js:116:25)
at dependencies.map.result (F:\React Native\AttendenceSystem\node_modules\metro\src\DeltaBundler\traverseDependencies.js:298:29)
at Array.map (<anonymous>)
at resolveDependencies (F:\React Native\AttendenceSystem\node_modules\metro\src\DeltaBundler\traverseDependencies.js:294:16)
at F:\React Native\AttendenceSystem\node_modules\metro\src\DeltaBundler\traverseDependencies.js:159:33
at Generator.next (<anonymous>)
at step (F:\React Native\AttendenceSystem\node_modules\metro\src\DeltaBundler\traverseDependencies.js:239:307)"}
processBundleResult
BundleDownloader.java:285
access$200
BundleDownloader.java:37
onResponse
BundleDownloader.java:163
execute
RealCall.java:153
run
NamedRunnable.java:32
runWorker
ThreadPoolExecutor.java:1113
run
ThreadPoolExecutor.java:588
run
Thread.java:818
该错误是因为您的本机项目版本反应。
你现在必须通过这个版本创建这样的项目--->
react-native init ProjectName --version 0.55.4
只需等待React Native的下一个版本让他们解决这个问题。
如果你的发现像本发明版本0.56那样反应你的package.json文件,请参阅依赖关系和devDependencies ---->
"react-native":"0.56.0"
在依赖项中然后将其更改为
"react-native":"0.55.4"
并在devDependencies中更改
"babel-preset-react-native": "5",
至
"babel-preset-react-native": "4.0.0",
最后跑
npm install
似乎降级react-native版本将解决问题。你使用的是最新的0.56.1吗?新版本非常不稳定,尤其是在运行Windows时。
降级到0.55.4应该可以解决您的问题:npm install react-native@0.55.4
你可以看看这个非常相似的问题:https://github.com/facebook/react-native/issues/14209
我假设您使用的是Windows。我最近得到了同样的错误,当我在github上搜索本地的反应问题时,看到人们改变了他们的package.json
文件。对我的案例有用的是,您可以根据自己的需要进行调整;
{
"name": "AwesomeProject",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.3.1",
"react-native": "0.55.4"
},
"devDependencies": {
"babel-jest": "22.4.4",
"babel-preset-react-native": "4.0.0",
"jest": "22.4.4",
"react-test-renderer": "16.3.1"
},
"jest": {
"preset": "react-native"
}
}
不要忘记先删除你的node_modules
文件夹,然后改变你的package.json
类似于上面,然后最后运行npm install
。
以上是关于react-native错误:无法解析模块`AccessibilityInfo`的主要内容,如果未能解决你的问题,请参考以下文章
未找到模块:错误:无法解析“../aws-exports”(React-Native Expo Web)
Expo React-Native 调试器 - 错误:无法从 ` 解析模块`./debugger-ui/debuggerWorker.cff11639.js`
修复错误:无法从“”解析模块“./index.android”
React-native,monorepo:无法解析模块@babel/runtime/helpers/interopRequireDefault