Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native - Unable to resolve module `@babel/runtime/helpers/interopRequireDefault` from 'index.js'

As mentioned in Unable to resolve module `@babel/runtime/helpers/interopRequireDefault`, I am experiencing the same error and the solution for that question doesn't solve the problem in my case.

Neither React Native - Unable to resolve module `@babel/runtime/helpers/interopRequireDefault` resolves my problem.

I am using

 OS: Windows 10 10.0.18362
    CPU: (8) x64 Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
    Memory: 2.03 GB / 7.92 GB
  Binaries:
    Node: 12.13.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.19.1 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.12.1 - C:\Program Files\nodejs\npm.CMD
  IDEs:
    Android Studio: Version  3.5.0.0 AI-191.8026.42.35.5977832
  npmPackages:
    react: 16.9.0 => 16.9.0
    react-native: 0.61.4 => 0.61.4

The error says:

error: bundling failed: Error: Unable to resolve module `@babel/runtime/helpers/interopRequireDefault` from `index.js`: @babel/runtime/helpers/interopRequireDefault could not be found within the project.

If you are sure the module exists, try these steps:
 1. Clear watchman watches: watchman watch-del-all
 2. Delete node_modules: rm -rf node_modules and run yarn install
 3. Reset Metro's cache: yarn start --reset-cache
 4. Remove the cache: rm -rf /tmp/metro-*
    at ModuleResolver.resolveDependency (C:\ReactProjects\testy\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:186:15)
    at ResolutionRequest.resolveDependency (C:\ReactProjects\testy\node_modules\metro\src\node-haste\DependencyGraph\ResolutionRequest.js:52:18)
    at DependencyGraph.resolveDependency (C:\ReactProjects\testy\node_modules\metro\src\node-haste\DependencyGraph.js:282:16)
    at Object.resolve (C:\ReactProjects\testy\node_modules\metro\src\lib\transformHelpers.js:267:42)
    at C:\ReactProjects\testy\node_modules\metro\src\DeltaBundler\traverseDependencies.js:426:31
    at Array.map (<anonymous>)
    at resolveDependencies (C:\ReactProjects\testy\node_modules\metro\src\DeltaBundler\traverseDependencies.js:423:18)
    at C:\ReactProjects\testy\node_modules\metro\src\DeltaBundler\traverseDependencies.js:275:33
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (C:\ReactProjects\testy\node_modules\metro\src\DeltaBundler\traverseDependencies.js:87:24)
 BUNDLE  [android, dev] ./index.js ░░░░░░░░░░░░░░░░ 0.0% (0/1), failed.

The module exists and I have tried the mentioned steps but still it doesnt work. The app actually builds successfully with message Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0. When the app runs the same error as above shows up. Any help is appreciated.

like image 394
Vipul Sharma Avatar asked Jan 21 '26 03:01

Vipul Sharma


1 Answers

In my case, the problem was not caused by RN, but by watchman.

There are two ways to solve this until a potential bug is fixed:

First would be to uninstall watchman.

Or manually edit the file node_modules/jest-haste-map/build/index.js to change:

    const crawl =
      canUseWatchman && this._options.useWatchman
        ? _watchman.default
        : _node.default;

To:

    const crawl =
      canUseWatchman && this._options.useWatchman
        ? _node.default
        : _node.default;

The latter will of course not persist over package upgrades.

like image 52
slhck Avatar answered Jan 22 '26 17:01

slhck



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!