All imports are undefined in new metro config (react-native 0.72 and higher)
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 5.6k
- Forks
- 696
- Avg merge
- 8m
- Merged PRs (30d)
- 7
Description
Bug Description
After upgrading from React Native 0.71 to 0.73, applications using module path aliases in Metro config crash with TypeError: Cannot read property 'rootReducer' of undefined when importing modules via configured aliases.
Steps to Reproduce
-
Set up RN 0.73 project with Metro alias configuration:
// metro.config.js alias: { src: path.resolve(__dirname, 'src') } -
Configure Babel module resolver:
// .babelrc ["module-resolver", { "alias": { "src": "./src" } }] -
Import module using alias:
// src/App.tsx import { rootReducer } from 'src/core/reducer'; -
Run the app
Expected Behavior
App should start normally and import modules correctly via configured aliases.
Actual Behavior
App crashes with error:
TypeError: Cannot read property 'rootReducer' of undefined
Environment
- React Native: 0.73.11
- Metro: 0.73.5
- Platform: Android/iOS
- Previous working version: RN 0.71
Additional Context
The issue appears to be related to changes in Metro's module resolution in RN 0.73. The same configuration works fine in RN 0.71. Module imports using relative paths work correctly, only alias-based imports fail.
Reproduction
Minimal reproduction case attached in the linked repository.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the attached minimal reproduction and inspect metro.config.js, .babelrc, and src/App.tsx. Run the React Native 0.73.11 reproduction with the alias import, then compare alias resolution with the working React Native 0.71 setup. Done means aliased imports resolve without the undefined-module crash on Android and iOS.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react-native, typescript
- Domain
- build-system, mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100