react / react/metro

All imports are undefined in new metro config (react-native 0.72 and higher)

Open
#1,544 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
5.6k
Forks
696
Avg merge
8m
Merged PRs (30d)
7

Description

minimal-repro.zip

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

  1. Set up RN 0.73 project with Metro alias configuration:

    // metro.config.js
    alias: { src: path.resolve(__dirname, 'src') }
    
  2. Configure Babel module resolver:

    // .babelrc
    ["module-resolver", { "alias": { "src": "./src" } }]
    
  3. Import module using alias:

    // src/App.tsx
    import { rootReducer } from 'src/core/reducer';
    
  4. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.