facebook / metro

🚇 The JavaScript bundler for React Native
https://metrobundler.dev
MIT License
5.2k stars 620 forks source link

Unable to resolve module @babel/runtime/helpers/interopRequireDefault from /Users/myapp/index.js #1357

Open keYa2508 opened 2 weeks ago

keYa2508 commented 2 weeks ago

Description

I get this error in react native cli app

Steps to reproduce

  1. Run the app with npm start.
  2. After app build error is getting

React Native Version

0.73.6

Affected Platforms

Runtime - Android, Runtime - iOS

Output of npx react-native info

info Fetching system and libraries information...
System:
  OS: macOS 14.6.1
  CPU: (8) arm64 Apple M1
  Memory: 118.41 MB / 8.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.17.0
    path: ~/.nvm/versions/node/v20.17.0/bin/node
  Yarn:
    version: 3.6.4
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.8.3
    path: ~/.nvm/versions/node/v20.17.0/bin/npm
  Watchman:
    version: 2024.09.23.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /Users/arulselvam/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.0
      - iOS 18.0
      - macOS 15.0
      - tvOS 18.0
      - visionOS 2.0
      - watchOS 11.0
  Android SDK: Not Found
IDEs:
  Android Studio: 2023.3 AI-233.14808.21.2331.11842104
  Xcode:
    version: 16.0/16A242d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.12
    path: /usr/bin/javac
  Ruby:
    version: 3.3.1
    path: /Users/arulselvam/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.3.1
    wanted: ^18.2.0
  react-native:
    installed: 0.73.9
    wanted: ^0.73.6
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

info React Native v0.75.3 is now available (your project is running on v0.73.9).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.75.3
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.75.3
info For more info, check out "https://reactnative.dev/docs/upgrading?os=macos".

Stacktrace or Logs

Error: Unable to resolve module @babel/runtime/helpers/interopRequireDefault from /Users/arulselvam/Work/Micromen/BsfAsset/index.js: @babel/runtime/helpers/interopRequireDefault could not be found within the project or in these directories:
  node_modules
> 1 | /**
    | ^
  2 |  * @format
  3 |  */
  4 |
    at ModuleResolver.resolveDependency (/Users/arulselvam/Work/Micromen/BsfAsset/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:139:15)
    at DependencyGraph.resolveDependency (/Users/arulselvam/Work/Micromen/BsfAsset/node_modules/metro/src/node-haste/DependencyGraph.js:232:43)
    at /Users/arulselvam/Work/Micromen/BsfAsset/node_modules/metro/src/lib/transformHelpers.js:156:21
    at resolveDependencies (/Users/arulselvam/Work/Micromen/BsfAsset/node_modules/metro/src/DeltaBundler/buildSubgraph.js:42:25)
    at visit (/Users/arulselvam/Work/Micromen/BsfAsset/node_modules/metro/src/DeltaBundler/buildSubgraph.js:83:30)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Promise.all (index 0)
    at async buildSubgraph (/Users/arulselvam/Work/Micromen/BsfAsset/node_modules/metro/src/DeltaBundler/buildSubgraph.js:103:3)
    at async Graph._buildDelta (/Users/arulselvam/Work/Micromen/BsfAsset/node_modules/metro/src/DeltaBundler/Graph.js:157:22)
    at async Graph.initialTraverseDependencies (/Users/arulselvam/Work/Micromen/BsfAsset/node_modules/metro/src/DeltaBundler/Graph.js:140:19)
info Stopping server

Reproducer

https://github.com/keYa2508

Screenshots and Videos

No response

react-native-bot commented 2 weeks ago
:warning: Newer Version of React Native is Available!
:information_source: You are on a supported minor version, but it looks like there's a newer patch available - 0.73.9. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.
react-native-bot commented 2 weeks ago
:warning: Missing Reproducible Example
:information_source: We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.
react-native-bot commented 2 weeks ago
:warning: Newer Version of React Native is Available!
:information_source: You are on a supported minor version, but it looks like there's a newer patch available - undefined. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.
react-native-bot commented 2 weeks ago
:warning: Missing Reproducible Example
:information_source: We could not detect a reproducible example in your issue report. Please provide either:
vzaidman commented 2 days ago

did you try updating @babel/runtime ?