Skip to content

Module @babel/runtime/helpers/interopRequireDefault does not exist in the Haste module map #21310

Closed

Description

@Aximem

Environment

React Native Environment Info:
System:
OS: macOS High Sierra 10.13.6
CPU: x64 Intel(R) Core(TM) i5-6360U CPU @ 2.00GHz
Memory: 408.65 MB / 8.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.12.0 - /usr/local/bin/node
Yarn: 1.3.2 - /usr/local/bin/yarn
npm: 6.4.1 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.0, macOS 10.14, tvOS 12.0, watchOS 5.0
Android SDK:
Build Tools: 23.0.1, 23.0.2, 23.0.3, 25.0.0, 25.0.2, 25.0.3, 26.0.2, 26.0.3, 27.0.1, 27.0.2
API Levels: 23, 24, 25, 26, 27
IDEs:
Android Studio: 3.0 AI-171.4443003
Xcode: 10.0/10A255 - /usr/bin/xcodebuild
npmPackages:
react: 16.5.0 => 16.5.0
react-native: 0.57.1 => 0.57.1
npmGlobalPackages:
create-react-native-app: 1.0.0
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7

Description

When starting a new project with react-native init then run iOS, I'm getting the error :

Module @babel/runtime/helpers/interopRequireDefault does not exist in the Haste module map

capture d ecran 2018-09-25 a 09 37 54

Reproducible Demo

react-native init myapp
// FIX CFBundleIdentifier issue with react-native upgrade
react-native run-ios
Get the error.

FIX

The issue can be fix by doing:
npm add @babel/runtime
npm install
But we shouldn't have to do all this stuff !

Activity

  1. sunnylqm commented on Sep 25, 2018

    @sunnylqm
    Contributor

    Should wait for this to be merged #21283

  2. Aximem commented on Sep 25, 2018

    @Aximem
    Author
  3. rodrigoelp commented on Sep 25, 2018

    @rodrigoelp

    I've just run into this issue... ever since xcode 10 came out, the number of issues have been out of this world

  4. Cnordbo commented on Sep 25, 2018

    @Cnordbo

    Had the same issue on W10 machine.
    Its a brand new setup.
    Suggested fix works.

      React Native Environment Info:
        System:
          OS: Windows 10
          CPU: x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
          Memory: 20.29 GB / 31.81 GB
        Binaries:
          npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
        IDEs:
          Android Studio: Version  3.2.0.0 AI-181.5540.7.32.5014246
    
  5. jlcool commented on Sep 25, 2018

    @jlcool
  6. silentsiri commented on Sep 25, 2018

    @silentsiri
  7. g4laura commented on Sep 25, 2018

    @g4laura

    for now since a lot of new changes are coming out, this fix worked for me:
    with npm:
    npm install --save @babel/runtime
    or with yarn:
    yarn add @babel/runtime
    (edited: if you're planning on waiting for the release that fixes this before releasing a new production build (like me) you can keep babel/runtime in devDependencies, but if you want to build a release build with this version of react-native, you need to put @babel/runtime in dependencies as the original poster said)

    if on ios you get _this._registerEvents is not a function, after a successful build
    do
    npm run start --reset-cache
    or
    react-native start --reset-cache

    edit:
    should add @babel/core, under resolutions, in package.json
    you may also need "babel-core": "7.0.0-bridge.0" in resolutions
    but this is more for react-native projects being upgraded..

  8. boovius commented on Sep 25, 2018

    @boovius

    wow @g4laura you da man (woman) ! 👍

  9. sungkhum commented on Sep 25, 2018

    @sungkhum

    You all just fixed the issues I've been having for two days (new to react native). Hopefully these bugs will be fixed, but in the mean time

    npm add @babel/runtime
    npm install
    

    worked for me. Thanks @Aximem

  10. masashi49 commented on Sep 26, 2018

    @masashi49

    私の環境です

    react-native-cli: 2.0.1  
    react-native: 0.57.0
    

    私もこのエラーが出ていましたが、

    npm add @babel/runtime  
    npm install
    

    これで動きました!
    ありがとう!!

  11. zenz commented on Sep 26, 2018

    @zenz

    just add @babel/runtime to devDependencies is ok.

    yarn add @babel/runtime --dev

  12. sunnylqm commented on Sep 26, 2018

    @sunnylqm
    Contributor

    Fixed in 1323acd but not landed in any version yet, will try to urge them to land in 0.57.2

  13. vyvee commented on Sep 26, 2018

    @vyvee

    for now after react-native init, since a lot of new changes are coming out, this fix worked for me (I got it from reading other issues):
    with npm:
    npm install --save-dev @babel/core
    npm install --save-dev @babel/runtime
    or with yarn:
    yarn add --dev @babel/core
    yarn add --dev @babel/runtime

    if on ios you get _this._registerEvents is not a function, after a successful build
    do
    npm run start --reset-cache
    or
    react-native start --reset-cache

    Thanks @g4laura ! I have been trying to fix this issue for 2 days & your suggestion (especially the inclusion of @babel/runtime) simply works!!
    I have tested it for Android, but not for iOS yet.

  14. punter82 commented on Sep 26, 2018

    @punter82

    Thanks @Aximem . Your suggestion worked !!!

  15. ThPch commented on Sep 26, 2018

    @ThPch

    Thanks for the short fix guys. I'm new to react-native too and it's been 3 days that from a scratch, clean windows install I'm trying to launch a very simple program. Finaly it's working. Thank you again

  16. 69 remaining items

  17. grantgeorge commented on Feb 14, 2020

    @grantgeorge

    Fun morning. I had to reset a bunch of dependencies and caches to get things to work. I ended up having to do a combination of things mentioned in this issue and this post.

    yarn add @babel/runtime --dev --exact
    

    Ensure that @babel/core and @babel/runtime had matching, exact versions in dev dependencies in package.json.

    "@babel/core": "7.8.4",
    "@babel/runtime": "7.8.4",
    

    Nuke & pave:

    rm -rf node_modules
    yarn cache clean -f
    watchman watch-del-all
    rm -rf $TMPDIR/metro*
    rm -rf $TMPDIR/react-native*
    yarn install
    react-native start --reset-cache
    
  18. robertoporlan commented on Mar 31, 2020

    @robertoporlan

    para mim o problema foi porque eu estou usando raiz personalizada. há um problema com a raiz personalizada no RN59: # 24432

    adicionar um arquivo metro.config à minha raiz personalizada com uma propriedade watch-folders resolveu meu problema:
    metro.config.js:

    module.exports = {
      watchFolders: [`${__dirname}/../..`],
    };
    

    Thank You so mutch! You save me! haha

  19. stale commented on Jul 3, 2020

    @stale

    Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

  20. added
    StaleThere has been a lack of activity on this issue and it may be closed soon.
    on Jul 3, 2020
  21. stale commented on Jul 11, 2020

    @stale

    Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

  22. hugoh59 commented on Sep 14, 2020

    @hugoh59

    I'm still getting this issue with react-native 0.63.2 and none of these solved it.

  23. OlegPanfyorov commented on Sep 16, 2020

    @OlegPanfyorov

    @hugoh59 Same for me, I'm really shocked. I tried everything. RN is a piece of shit

  24. artadmire commented on Dec 25, 2020

    @artadmire

    I'm still getting this issue with react-native 0.63.2 and none of these solved it. Please helper!

  25. lchnnl commented on Feb 14, 2021

    @lchnnl

    I had the same issue. This is what i did to resolve.
    Update homebrew (brew update)
    Upgrade watchman (brew upgrade watchman)
    Made the changes as suggested by (here)[https://github.com//issues/27712#issuecomment-572889578]

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

    Then ran my npx react-native bundle ....
    After successful run
    I changed the code back to the original

    const crawl =
          canUseWatchman && this._options.useWatchman
            ? _watchman.default
            : _node.default;
    
  26. kovkev commented on May 26, 2021

    @kovkev

    I am getting this issue with

    System:
        OS: macOS 11.1
        CPU: (8) x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
        Memory: 474.82 MB / 16.00 GB
        Shell: 3.2.57 - /bin/bash
      Binaries:
        Node: 14.15.0 - ~/.nvm/versions/node/v14.15.0/bin/node
        Yarn: 1.22.4 - ~/project/node_modules/.bin/yarn
        npm: 6.14.8 - ~/.nvm/versions/node/v14.15.0/bin/npm
        Watchman: 4.9.0 - /usr/local/bin/watchman
      Managers:
        CocoaPods: 1.9.3 - /usr/local/lib/ruby/gems/2.7.0/bin/pod
      SDKs:
        iOS SDK:
          Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
        Android SDK:
          API Levels: 23, 27, 28, 29, 30
          Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.3
          System Images: android-28 | Intel x86 Atom, android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom_64, android-28 | Google Play Intel x86 Atom, android-29 | Google Play Intel x86 Atom, android-R | Google Play Intel x86 Atom
          Android NDK: Not Found
      IDEs:
        Android Studio: 4.1 AI-201.8743.12.41.6858069
        Xcode: 12.4/12D4e - /usr/bin/xcodebuild
      Languages:
        Java: 11.0.2 - /usr/bin/javac
      npmPackages:
        @react-native-community/cli: Not Found
        react: 17.0.1 => 17.0.1
        react-native: 0.64.1 => 0.64.1
        react-native-macos: Not Found
      npmGlobalPackages:
        *react-native*: Not Found
    

    I am not sure how to troubleshoot it. I've tried the solutions presented here.

  27. matthew-dean commented on Oct 14, 2022

    @matthew-dean

    Getting this issue with importing directly a TypeScript module package. Wiping and re-installing with pnpm install has not worked.

  28. kockar96 commented on Jan 6, 2023

    @kockar96

    Someone may find this helpful. I had the same problem while using turborepo and Expo.
    Resolved it by adding 'node-linker=hoisted' to .npmrc.

  29. chiraag918 commented on Apr 10, 2023

    @chiraag918

    I am facing a similar issue, but it is on reactjs. So I have a component library which I have published on github packages using Rollup as my bundler. The component library is also developed in reactjs. So when I install this library on a consumer application(reactjs web app), I'm getting the error as shown in the attached screenshot. Until a month and a half ago everything was working fine. After which I published a new version and ever since that I'm facing the same issue. The version previous to this new version that I published a month and a half ago is working fine but anything published after this version throws up the same error. I even reverted the code back to how it is on the version that is working, but no luck. Requesting help on this issue. Need to resolve this as early as possible.

    Screenshot 2023-04-10 at 12 40 33 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugStaleThere has been a lack of activity on this issue and it may be closed soon.Tech: Bundler 📦This issue is related to the bundler (Metro, Haul, etc) used.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions