Unable to resolve module @react-native-async-storage/async-storage

Viewed 3084

Getting this error after adding aws-amplify to the project, Did complete setup for aws-amplify according to the docs, then pod install and react-native run-ios I have also tried changing the import statement as mentioned in the suggestion below error, still doesn't work, Thanks in advance.

  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)```
3 Answers

Install Amplify libraries: here,

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

After that Try cleaning the project if there is an issue,

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

I just deleted the app from the emulator and reinstalled it and it finally worked after a long time of research that led to no emends!

I resolve so - in package.json

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