Requiring unknown module "undefined"
See original GitHub issueError 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
Issue Analytics
- State:
- 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