无法解析模块 @react-native-async-storage/async-storage

在将 aws-amplify 添加到项目后出现此错误,是否根据文档完成了 aws-amplify 的设置,然后是 pod install 和 react-native run-ios 我还尝试更改以下错误建议中提到的导入语句,还是不行,先谢谢了。


  node_modules/@aws-amplify/core/node_modules
  node_modules
  ../node_modules

If you are sure the module exists, try these steps:
 1. Clear watchman watches: watchman watch-del-all
 2. Delete node_modules and run yarn install
 3. Reset Metro's cache: yarn start --reset-cache
 4. Remove the cache: rm -rf /tmp/metro-*
  11 |  * and limitations under the License.
  12 |  */
> 13 | import AsyncStorage from '@react-native-async-storage/async-storage';
     |                           ^
  14 | var MEMORY_KEY_PREFIX = '@MemoryStorage:';
  15 | var dataMemory = {};
  16 | /** @class */
    at ModuleResolver.resolveDependency (/Users/monk/Projects/Airbnb/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:234:15)
    at DependencyGraph.resolveDependency (/Users/monk/Projects/Airbnb/node_modules/metro/src/node-haste/DependencyGraph.js:413:43)
    at Object.resolve (/Users/monk/Projects/Airbnb/node_modules/metro/src/lib/transformHelpers.js:317:42)
    at resolve (/Users/monk/Projects/Airbnb/node_modules/metro/src/DeltaBundler/traverseDependencies.js:629:33)
    at /Users/monk/Projects/Airbnb/node_modules/metro/src/DeltaBundler/traverseDependencies.js:645:26
    at Array.reduce (<anonymous>)
    at resolveDependencies (/Users/monk/Projects/Airbnb/node_modules/metro/src/DeltaBundler/traverseDependencies.js:644:33)
    at /Users/monk/Projects/Airbnb/node_modules/metro/src/DeltaBundler/traverseDependencies.js:329:33
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/Users/monk/Projects/Airbnb/node_modules/metro/src/DeltaBundler/traverseDependencies.js:137:24)``` 

 `` `
stack overflow Unable to resolve module @react-native-async-storage/async-storage
原文答案
author avatar

接受的答案

安装 Amplify 库: here

yarn add @react-native-async-storage/async-storage

之后,如果有问题,请尝试清理项目,

rm -rf $TMPDIR/metro-* && rm -rf $TMPDIR/haste-* && watchman watch-del-all && yarn cache clean --force && rm -rf ios/build && rm -rf node_modules/
yarn install
rm -rf pods && pod install

答案:

作者头像

我只是从模拟器中删除了该应用程序并重新安装了该应用程序,并且经过很长时间的研究,它终于起作用了!

作者头像

我解决了 - 在 package.json

"@react-native-community/async-storage": "https://github.com/react-native-async-storage/async-storage",