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

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

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!

delete your node_modules & reinstall your node_modules

I resolve so - in package.json
"#react-native-community/async-storage": "https://github.com/react-native-async-storage/async-storage",

Related

storybook : Unable to resolve module path from node_modules/#storybook/store/dist/cjs/autoTitle.js

I'm using a storybook with a react native project and this project is inside a lerna project. while running yarn && yarn start in one terminal then yarn run-android I have this error:
error: Error: Unable to resolve module path from /home/front/node_modules/#storybook/store/dist/cjs/autoTitle.js: path could not be found within the project or in these directories:
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-*
38 | var _startCase = _interopRequireDefault(require("lodash/startCase"));
39 |
> 40 | var _path = _interopRequireDefault(require("path"));
| ^
41 |
42 | var _slash = _interopRequireDefault(require("slash"));
43 |
at ModuleResolver.resolveDependency (/home/front/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:129:15)
at DependencyGraph.resolveDependency (/home/front/node_modules/metro/src/node-haste/DependencyGraph.js:288:43)
at Object.resolve (/home/front/node_modules/metro/src/lib/transformHelpers.js:129:24)
at resolve (/home/front/node_modules/metro/src/DeltaBundler/traverseDependencies.js:396:33)
at /home/front/node_modules/metro/src/DeltaBundler/traverseDependencies.js:412:26
at Array.reduce (<anonymous>)
at resolveDependencies (/home/front/node_modules/metro/src/DeltaBundler/traverseDependencies.js:411:33)
at processModule (/home/front/node_modules/metro/src/DeltaBundler/traverseDependencies.js:140:31)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Done in 451.87s.
This file /home/front/node_modules/#storybook/store/dist/cjs/autoTitle.js do exists. so for me The storybook need to know how to look for this file but I don't know how to tell him.
Do you have any idea ?

React Native 0.59 -> 0.60 - Unable to resolve module `NativeModules`

I want to make sure that my native library works on 0.6x React Native. I've got a version of the library working on 0.59.x but when I run it on 0.6x I get the following json response (together with server 500):
Body:
{"originModulePath":"screens/custom-action-screen.js","targetModuleName":"NativeModules","message":"Unable to resolve module `NativeModules` from `screens/custom-action-screen.js`: NativeModules could not be found within the project.\n\nIf you are sure the module exists, try these steps:\n 1. Clear watchman watches: watchman watch-del-all\n 2. Delete node_modules: rm -rf node_modules and run yarn install\n 3. Reset Metro's cache: yarn start --reset-cache\n 4. Remove the cache: rm -rf /tmp/metro-*","errors":[{"description":"Unable to resolve module `NativeModules` from `screens/custom-action-screen.js`: NativeModules could not be found within the project.\n\nIf you are sure the module exists, try these steps:\n 1. Clear watchman watches: watchman watch-del-all\n 2. Delete node_modules: rm -rf node_modules and run yarn install\n 3. Reset Metro's cache: yarn start --reset-cache\n 4. Remove the cache: rm -rf /tmp/metro-*"}],"name":"Error","stack":"Error: Unable to resolve module `NativeModules` from `screens/custom-action-screen.js`: NativeModules could not be found within the project.\n\nIf you are sure the module exists, try these steps:\n 1. Clear watchman watches: watchman watch-del-all\n 2. Delete node_modules: rm -rf node_modules and run yarn install\n 3. Reset Metro's cache: yarn start --reset-cache\n 4. Remove the cache: rm -rf /tmp/metro-*\n at ModuleResolver.resolveDependency (/Users/krzysztofkubicki/Workspace/PublicRelease/React-Native-Dev/SampleApp/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:186:15)\n at ResolutionRequest.resolveDependency (/Users/krzysztofkubicki/Workspace/PublicRelease/React-Native-Dev/SampleApp/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:52:18)\n at DependencyGraph.resolveDependency (/Users/krzysztofkubicki/Workspace/PublicRelease/React-Native-Dev/SampleApp/node_modules/metro/src/node-haste/DependencyGraph.js:282:16)\n at Object.resolve (/Users/krzysztofkubicki/Workspace/PublicRelease/React-Native-Dev/SampleApp/node_modules/metro/src/lib/transformHelpers.js:267:42)\n at /Users/krzysztofkubicki/Workspace/PublicRelease/React-Native-Dev/SampleApp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:426:31\n at Array.map (<anonymous>)\n at resolveDependencies (/Users/krzysztofkubicki/Workspace/PublicRelease/React-Native-Dev/SampleApp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:423:18)\n at /Users/krzysztofkubicki/Workspace/PublicRelease/React-Native-Dev/SampleApp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:275:33\n at Generator.next (<anonymous>)\n at asyncGeneratorStep (/Users/krzysztofkubicki/Workspace/PublicRelease/React-Native-Dev/SampleApp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:87:24)"}
So my quetion is: How is it possible that the NativeModules were "visible" in previous version? All I did was upgrade the react native version and left all the code as it was.
It still works on 0.59.

Unable to resolve module `#babel/runtime/helpers/interopRequireDefault`

When creating a new react native project using the standard react-native init MyApp and running react-native run-ios for the first time I'm seeing the following error
error: bundling failed: Error: Unable to resolve module `#babel/runtime/helpers/interopRequireDefault` from `/Users/chrisedgington/Development/ReactNative/SixNationsPredictor/index.js`: Module `#babel/runtime/helpers/interopRequireDefault` 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 (/Users/chrisedgington/Development/ReactNative/MyApp/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:209:1301)
at ResolutionRequest.resolveDependency (/Users/chrisedgington/Development/ReactNative/MyApp/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:83:16)
at DependencyGraph.resolveDependency (/Users/chrisedgington/Development/ReactNative/MyApp/node_modules/metro/src/node-haste/DependencyGraph.js:238:485)
at Object.resolve (/Users/chrisedgington/Development/ReactNative/MyApp/node_modules/metro/src/lib/transformHelpers.js:180:25)
at dependencies.map.result (/Users/chrisedgington/Development/ReactNative/MyApp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:311:29)
at Array.map (<anonymous>)
at resolveDependencies (/Users/chrisedgington/Development/ReactNative/MyApp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:307:16)
at /Users/chrisedgington/Development/ReactNative/MyApp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:164:33
at Generator.next (<anonymous>)
at step (/Users/chrisedgington/Development/ReactNative/MyApp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:266:307)
I've tried running the suggested but still see the same issue. I've seen a few posts about similar issues but nothing specifically seems to say how to resolve the problem in react-native.
macOS: 10.13.6
node: 8.11.3
react-native-cli: 2.0.1
react-native: 0.57.1
Have a go and try:
npm add #babel/runtime
Or upgrade babel runtime:
"#babel/runtime": "7.0.0-beta.55"
I tried all the things mentioned above, and, I found myself here again tonight.
Running from a nrwl mono repo, I had to cd into the app that was having the problem and run.
jest --clearCache
You should first quit the metro terminal before executing
npm add #babel/runtime
npm install
You should add and install babel for your projects
npm add #babel/runtime
npm install
If The error is not fixed, Try:
npm start --reset-cache
The issue for me was that #babel/runtime was installed as a dev-dependency instead of just a normal (non-dev) dependency
Try to update your npm version first
npm update -g npm#version or sudo npm -gf update npm#version
and then just add the babel runtime at your react native project
npm add #babel/runtime
Try upgrading your packages. You could have an old package causing the problem:
yarn upgrade-interactive --latest
Current error message suggests these steps to fix this:
Clear watchman watches: watchman watch-del-all
Delete node_modules: rm -rf node_modules and run yarn install
Reset Metro's cache: yarn start --reset-cache
Remove the cache: rm -rf /tmp/metro-*
The last one solved it for me.
I had this problem today (April 2021), and I could solve it only by removing the webpack-node-externals package from my webpack configuration.
For me the solution was (Mac):
Stop IntelliJ
Enter terminal
Run: npx browserslist#latest --update-db -g
Run: npm cache verify
Start IntelliJ
If still not working:
Delete node_modules fron project if exists
Run: npm cache verify
Run npm install -f in project
Run: npx browserslist#latest --update-db -g
Problem:
I was in the middle of upgrading flow to typescript and I used #khanacademy/flow-to-ts to convert js files to ts. the lib not only changed the js files of the app but also it converted all js files in node_modules directory.
Solution:
I had to remove the node_modules and npm -i. This time when I checked the node_modules the interopRequireDefault.js file was there.
In case you are working with Yarn workspaces please note you are running react-native start from the right project...
Install latest Babel/runtime
=> install #babel/runtime
After that clean or reset the cache
=> npm start -- --reset-cache after
or
npm cache clean --force
I accidentally deleted my node_modules and package-lock.json. I used npm i to regenerate them and suddenly I was getting the above error. I solved it in two ways.
By uninstalling the app and using the following commands.
npx jest --clearCache
npm update
npm i
npx react-native run-android
By deleting the local repository and re-cloning it.
Hope this helps you.
I just uninstalled watchman. It worked for me.
brew uninstall watchman
Someone may find this helpful. I had the same problem while using turborepo and Expo.
Resolved it by adding 'node-linker=hoisted' to .npmrc.
Had this issue none of the above listed solutions worked for me, I had to go to node_modules/jest-haste-map/build/index.js
changed const crawl = canUseWatchman && this._options.useWatchman ? _watchman.default : _node.default;
to const crawl = canUseWatchman && this._options.useWatchman ? _node.default : _node.default;

Cannot read property 'prev' in React Native

here I have attached image of my error.My app worked properly.Then without any code change I got this issue.tried different methods.but could not solved this.I cleared watchman also.But I was not worked for me.Any one can help me ?
Finally found the solution.
To resolve try the following:
Clear watchman watches: watchman watch-del-all.
Delete the node_modules folder: rm -rf node_modules && npm install.
Reset packager cache: rm -fr $TMPDIR/react-* or npm start --reset-cache.

Packager won't start after React Native Update

I updated my React-Native from 0.15.0 to 0.18.1 and it's giving the following error now. (When trying with react-native start)
Error building DependencyGraph:
Error: Naming collision detected: /Users/mymac/research/react-native/rotater/ios-templates/node_modules/fbjs/lib/warning.js collides with /Users/mymac/research/react-native/rotater/ios-templates/node_modules/react-native/node_modules/fbjs/lib/warning.js
at HasteMap._updateHasteMap (HasteMap.js:132:13)
at HasteMap.js:103:28
at tryCallOne (/Users/mymac/research/react-native/rotater/ios-templates/node_modules/promise/lib/core.js:37:12)
at /Users/mymac/research/react-native/rotater/ios-templates/node_modules/promise/lib/core.js:103:15
at flush (/Users/mymac/research/react-native/rotater/ios-templates/node_modules/asap/raw.js:50:29)
at doNTCallback0 (node.js:428:9)
at process._tickCallback (node.js:357:13)
What is the fix for this?
Try this:
rm -rf node_modules/
npm i
npm i fbjs
find . -name 'fbjs' -print
delete all but the top-level fbjs
rm -rf $TMPDIR/react-*
watchman watch-del-all
npm cache clean
I had the same issue after upgrading to version .18.1, this fixed if for me.
Have you tried deleting your node_modules folder then reinstalling using npm install?