react-native: Requiring unknown module "undefined"
Error after upgrading 0.54.0 from 0.53.3.
Requiring unknown module “undefined”.If you are sure the module is there, try restarting Metro Bundler. You may also want to run yarn
, or npm install
(depending on your environment).
handleException @ ExceptionsManager.js:65
handleError @ InitializeCore.js:115
reportFatalError @ error-guard.js:44
guardedLoadModule @ require.js:141
_require @ require.js:130
executeApplicationScript @ debuggerWorker.js:40
(anonymous) @ debuggerWorker.js:65
ExceptionsManager.js:65 Module AppRegistry is not a registered callable module (calling runApplication)
Environment
Environment: OS: macOS High Sierra 10.13.3 Node: 8.9.4 Yarn: 1.5.1 npm: 5.6.0 Watchman: 4.9.0 Xcode: Xcode 9.2 Build version 9C40b Android Studio: 3.0 AI-171.4443003
Packages: (wanted => installed) react: ^16.3.0-alpha.1 => 16.3.0-alpha.1 react-native: 0.54.0 => 0.54.0
Expected Behavior
App should launch
Actual Behavior
UnknownModuleError
Steps to Reproduce
react-native run-android
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 41
- Comments: 49 (6 by maintainers)
I was able to resolve this issue for my project by doing the following…
Given that this issue seems to be caused when there is
import {y} from './x'
andimport {z} from 'myapp/x'
in the same file, I was able to track down these files with these steps:_require
items in the stack trace. See screenshot below:Be sure you have set the REACT_EDITOR variable set so react-native can open the file with an editor
In my file (actions.js), before changes
actions.js after changes
This will also work:
Now run your app again, and you may get the same error, but it will now point to a different file (assuming you have resolved all imports in the first file). If you get the error in a new file, repeat steps above until all files are cleaned up.
I had to do this 3-4 times before I had found all of the modules that have
import {y} from './x'
andimport {z} from 'myapp/x'
in the same file. Hope this helps someone else.It will work but its up to you
Fix your import, dont use …/…/ for your import, use @.
Same problem
you can use a eslint rule to help on this https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md
Even if that might work, I don’t think this is the solution for the problem… The problem is that the imports are failing and I don’t really understand why…
Reverted to 0.53.3 for now…
It looks like the issue is if you have the same file imported twice by different names in
This happens also on iOS. Is this related to the metro-bundler? 0.54.1 is facing the same issue and it´s currently blocking from upgrading. Moving to absolute paths would be a huge change right now, so we planned to move the components one after another instead of all 500 files.
Is there maybe any workaround to allow relative paths through the rn-cli.config ?
i also solved with package.json manipulatoin check this out #2051
https://github.com/react-community/react-native-maps/issues/2051#issuecomment-370055156
Seems like this has been fixed in metro with this commit and released in v0.30.2, which react native just bumped its dependency to in master with this commit so hopefully its included in the next release
React native requiring unknown module “492”, if you are sure module is there try restarting metro-bundler.
I got the above error on android OS. I closed the app on the multi-task button and opened the app again from within the emulator and it worked for me.
Are you using react-native-maps ?
If so, react-native-maps may be the problem preventing upgrading to 0.54.0
See: Requiring unknown module “undefined”. #2051
ok fixed my problem, in my case it was An import for a component using relative path, instead of the @ way. replacing that fixed it
Got exacty this error when I forgot to install and link (pod install)
react-native-vector-icons
Below is what I started seeing, it was working fine, suddenly started seeing below, no clue of what file is causing, tried changing imports
@wildseansy saved me
Hey guys, for me the problem was the following in my index.js (or whatever you call it)
MyApp was exported like
so instead I did the following
So you may try converting some default exports to named ones.
@rnageli - that is likely a different issue. This one produces
Requiring unknown module "undefined"
, on both Android and iOS consistently. Have tried restarting metro-bundler, re-installing node_modules, clearing caches etc… Doesn’t help.