-
Notifications
You must be signed in to change notification settings - Fork 626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Metro can not find index.cjs which is designated in package.json's main key #815
Comments
Thanks @junderw for forwarding this on - reply below for your users This is a known issue (eg #535) with the way Metro's file crawl works - it needs to know all source extensions ahead of time - and we don't currently include We're working on it - there are some subtleties about a "correct", spec-compliant solution (comments under #770) but the practical advice for now is to add In a stock React Native project you should have a // metro.config.js
const { getDefaultConfig } = require("metro-config");
const { resolver: defaultResolver } = getDefaultConfig.getDefaultValues();
module.exports = {
resolver: {
...defaultResolver,
sourceExts: [
...defaultResolver.sourceExts,
"cjs",
],
}
// ...Any other config
} |
@robhogan adding that did not seem to solve the issue, I am still getting:
Here's my metro.config.js
Is there anything else I need to be doing? |
Same issue here |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
See this issue: bitcoinjs/tiny-secp256k1#84
Our package uses exports to expose ESM and CJS. But someone said their tool needed a legacy main key for package.json pointing to CJS...
So the current state is exports + a main pointing to CJS (.cjs file)
I was given this as an issue downstream and asked them to report the issue, but they did not... If the solution doesn't jump out at anyone feel free to close it... as figuring out the repro steps from an unresponsive reporter will take too long.
Perhaps some regex isn't including .cjs / .mjs files? (shot in the dark)
The text was updated successfully, but these errors were encountered: