Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Build fails if package doesn't have "main" param in its package.json #1424

Open
Amir-A-M opened this issue Jan 6, 2025 · 0 comments
Open

Comments

@Amir-A-M
Copy link

Amir-A-M commented Jan 6, 2025

Hello

Metro bundler fails if a package doesn't have "main" param in its package.json

"main" is not part of the spec for ESM module

I was trying to build my Expo React Native app, and I was stuck at some error like this:

Starting Metro Bundler
Error: While trying to resolve module `react-merge-refs` from file `/home/expo/workingdir/build/src/Hook/useDraggableScroll.ts`, 
the package `/home/expo/workingdir/build/node_modules/react-merge-refs/package.json` was successfully found. 
However, this package itself specifies a `main` module field that could not be resolved (`/home/expo/workingdir/build/node_modules/react-merge-refs/index`. 
Indeed, none of these files exist:

I Added Blow line to the 'react-merge-refs' package.json in a fork and it fixed it.
metro bundler should handle this

"main": "./dist/index.mjs",

Thanks and Regards

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant