garganurag893 / react-native-phone-number-input

React Native component for phone number.
MIT License
372 stars 212 forks source link

Error: While trying to resolve module `react-async-hook` #108

Open maakle opened 2 years ago

maakle commented 2 years ago

When i try to render a text input I receive the following error message:

error: Error: While trying to resolve module `react-async-hook` from file 
`.../node_modules/react-native-country-picker-modal/lib/Flag.js`, the package 
`.../node_modules/react-native-country-picker-modal/node_modules/react-async-hook/package.json` was successfully found. 

However, this package itself specifies a `main` module field that could not be resolved (`.../node_modules/react-native-country-picker-modal/node_modules/react-async-hook/react-async-hook.esm.js`. Indeed, none of these files exist:

  * .../node_modules/react-async-hook/react-async-hook.esm.js(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.mjs|.native.mjs|.mjs)
  * .../node_modules/react-async-hook/react-async-hook.esm.js/index(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.mjs|.native.mjs|.mjs)

Seems like it's unable to pull a sub module or what's the error? I also tried installing react-async-hook separately, but didn't seem to help. Any other ideas?

MuhammadAbdullah54321 commented 1 year ago

I am getting the same issue

MuhammadAbdullah54321 commented 1 year ago

Alright so I have found a work around for this.

Actually the issues is that package is not able to find this file react-async-hook.esm.js on the given path. Currently this file react-async-hook.esm.js is in ...node_modules/react-async-hook/dist/react-async-hook.esm.js

So what I did is that I made a copy of this file and pasted in desired location which is directly in package folder Now path of this file looks like this ...node_modules/react-async-hook/react-async-hook.esm.js Note that dist is missing in new path. And then I just patched my package

Would like to mention that I haven't deleted from original location ... I just made a copy and pasted it my desired location. Here is screenshot of my current hierarchy of files:

Screenshot 2022-09-25 at 9 54 16 PM
GibbyBox commented 11 months ago

Optionally, you can also patch package.json to include the dist folder in the module field like so

-  "module": "react-async-hook.esm.js",
+  "module": "dist/react-async-hook.esm.js",