Skip to content
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

Requiring unknown module "undefined" #152

Closed
andrew-wagner89 opened this issue Mar 13, 2018 · 6 comments
Closed

Requiring unknown module "undefined" #152

andrew-wagner89 opened this issue Mar 13, 2018 · 6 comments

Comments

@andrew-wagner89
Copy link

Do 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

@rafeca
Copy link
Contributor

rafeca commented Mar 13, 2018

Thanks for reporting @andrew-wagner89 ! if you're able to create the repro example it will help us find the root cause

@rafeca
Copy link
Contributor

rafeca commented Mar 13, 2018

You can also try modifying my test RN repo and if you can reproduce it there send a PR so I can take a look at it

@rafeca
Copy link
Contributor

rafeca commented Mar 13, 2018

Ok I've been able to reproduce the issue thanks to the information in react-native-maps/react-native-maps#2051 .

The problem is happening when there are 2 requires to the same file but with different forms in the same module, for example:

const a = require('./a');
const a1 = require('./a.js');

This is what happened to react-native-maps (although they've just fixed it in react-native-maps/react-native-maps@0e201a9).

I'm working on a fix to metro ATM

@andrew-wagner89
Copy link
Author

Ah that makes sense, in most cases we use @providesModule, but if its in the same folder we use relative imports. Good catch!

@ckknight
Copy link

I wish it were obvious which module was causing this problem in my codebase.

@mikehuebner
Copy link

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.

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

No branches or pull requests

4 participants