Home > Back-end >  Error: Unable to resolve module @react-native-community/async-storage IOS
Error: Unable to resolve module @react-native-community/async-storage IOS

Time:02-08

I am trying to run my react native project In my IOS device. I start my server with npx react-native start then I start my app with Xcode. And I get this error:

error: Error: Unable to resolve module @react-native-community/async-storage from /Users/nicolelopez/dev/LeksPlay/src/Core/onboarding/utils/AuthDeviceStorage.js: @react-native-community/async-storage could not be found within the project or in these directories:
  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-*
> 1 | import AsyncStorage from '@react-native-community/async-storage'
    |                           ^
  2 |
  3 | const SHOULD_SHOW_ONBOARDING_FLOW = 'SHOULD_SHOW_ONBOARDING_FLOW'

what I have tried:

  1. I have followed the commands I get In the error message:
 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-*
  1. i have deleted node_modules and my package.lock.json and have re-installed yarn and done a pod install.

  2. i have tried to restart the computer

  3. i have tried to do a yarn add @react-native-community/async-storage

  4. i am running on node 14 - because I have run in to similar issues with a higher version of node.

  5. i am running Xcode in Rosetta mode - since I am on a Mac M1.

  6. i have tried to change my AsyncStorage import to import AsyncStorage from '@react-native-async-storage/async-storage';

  7. I have also tried to add pod 'RNCAsyncStorage', :path => '../node_modules/@react-native-community/async-storage'

but they all result in the same issue - with is the error code I posted. It gets no different no matter what I try. I am really new to react native, this may be a common issue but I can't seem to find anything that helps.

CodePudding user response:

From the deprecated @react-native-community/async-storage

Having the two will lead to issues.

If the issue still persist, try to clear all the cached, there is a good tool that will help you clean your react native project: https://github.com/taboulot/rn-game-over

npx rn-game-over --all

If you still have the issue afterward, please update your question with the new detail.

  •  Tags:  
  • Related