Skip to content

Issue with component dependency on the web #543

@lil-armstrong

Description

@lil-armstrong

Issue Description

After installing the library and importing it, I get the following error:

Uncaught Error
InternalError Metro has encountered an 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-native-country-picker-modal/node_modules/react-async-hook/react-async-hook.esm.js(.web.ts|.ts|.web.tsx|.tsx|.web.mjs|.mjs|.web.js|.js|.web.jsx|.jsx|.web.json|.json|.web.cjs|.cjs|.web.scss|.scss|.web.sass|.sass|.web.css|.css)
  *node_modules/react-native-country-picker-modal/node_modules/react-async-hook/react-async-hook.esm.js/index(.web.ts|.ts|.web.tsx|.tsx|.web.mjs|.mjs|.web.js|.js|.web.jsx|.jsx|.web.json|.json|.web.cjs|.cjs|.web.scss|.scss|.web.sass|.sass|.web.css|.css): node_modules/metro/src/node-haste/DependencyGraph.js (251:17)

�[0m �[90m 249 |�[39m         }
 �[90m 250 |�[39m         �[36mif�[39m (error �[36minstanceof�[39m �[33mInvalidPackageError�[39m) {
�[31m�[1m>�[22m�[39m�[90m 251 |�[39m           �[36mthrow�[39m �[36mnew�[39m �[33mPackageResolutionError�[39m({
 �[90m     |�[39m                 �[31m�[1m^�[22m�[39m
 �[90m 252 |�[39m             packageError�[33m:�[39m error�[33m,�[39m
 �[90m 253 |�[39m             originModulePath�[33m:�[39m �[36mfrom�[39m�[33m,�[39m
 �[90m 254 |�[39m             targetModuleName�[33m:�[39m to�[33m,�[39m�[0m

On Android and IOS, the component renders and works properly, but only throws an error on web

Steps to Reproduce / Code Snippets

  1. Install the library as instructed in the documentation
  2. Run the web app

Expected Results

The component should render properly without error

Additional Information

Nodejs version: v22.14.0
React version: v19.0.0
React Native version: v0.79.4
react-native-country-picker-modal version: ˆv2.0.0
Platform(s) (iOS, Android, web, or all?): web
TypeScript version:5.8.3

I am developing using Expo workflow and using the Expo GO app

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions