Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Requiring unknown module "undefined"

See original GitHub issue

Do you want to request a feature or report a 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:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

rafecacommented, Mar 13, 2018

Ok I’ve been able to reproduce the issue thanks to the information in .

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

I’m working on a fix to metro ATM

mikehuebnercommented, Jun 2, 2018

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Requiring unknown module "undefined". If you are sure ...
I had a similar problem with another npm package, then I went to the npm package node module js file. There you will...
Read more >
ERROR Error: Requiring unknown module "undefined"
I already try remove node_modules. I tried use Material Bottom Tab but i get the same error. edit 1. ERROR TypeError: undefined is...
Read more >
[Solved]-Requiring unknown module "undefined"-React Native
Coding example for the question Requiring unknown module "undefined"-React Native.
Read more >
Requiring unknown module "undefined". If you are sure the ...
Error: Requiring unknown module "undefined". If you are sure the module exists, try restarting Metro. You may also want to run yarn or...
Read more >
requiring unknown module 1298
Requiring unknown module "573".If you are sure the module is there, try restarting Metro Bundler. Requiring unknown module “undefined” on react-native-maps. 1.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found