Requiring unknown module "undefined"
See original GitHub issueDo you want to request a feature or report a bug?
Bug
What is the current behavior?
Moving this issue from react native to here
When creating a dev build on react native 0.54.2, the app never starts due to the error ‘Requiring unknown module “undefined”. If you are sure the module is there, try restarting Metro Bundler.’
The dev build had no errors bundling when React native was at v0.53.0, and the Metro version was bumped in the upgrade
This error occurs for some relative imports in the project. I’m not sure which relative imports work and which don’t, I’m trying to create a minimal example. Converting the problem ones to @providesModule imports solves the issue, but that is just a workaround and a hassle for larger projects.
I’ve tried using yarns “resolutions” in my package.json to bump Metro to v0.29.0 and v0.30.0, but the bundler wouldn’t even start due to a “Cannot read property ‘length’ of undefined” error.
my resolutions section to bump metro to v0.30.0:
"resolutions": {
"metro": "^0.30.0",
"metro-core": "^0.30.0"
}
If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can yarn install
and yarn test
.
in progress…
What is the expected behavior?
A project which bundled without error for RN v0.53.x will bundle successfully in RN 0.54.x
Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.
react native version: 0.54.2 metro version: 0.28.0, 0.29.0, and 0.30.0 node version: 8.4.0 yarn version: 1.5.1
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:6 (3 by maintainers)
Ok I’ve been able to reproduce the issue thanks to the information in https://github.com/react-community/react-native-maps/issues/2051 .
The problem is happening when there are 2 requires to the same file but with different forms in the same module, for example:
This is what happened to
react-native-maps
(although they’ve just fixed it in https://github.com/react-community/react-native-maps/commit/0e201a9a2ca833728b20526049c172e7240e4d7c).I’m working on a fix to metro ATM
I’m still seeing this issue and looking for a fix. I’ve tried renaming modules, moving files, making the exports all named, nothing seems to work.