babel: 7.13 "_interopRequireDefault is not a function"

In addition to https://github.com/babel/babel/issues/12851

If you set resolutions for @babel/core to ~7.12.0 you then get this error:

   8 | exports.navigateTo = exports.replace = exports.push = exports.navigate = exports.default = void 0;
   9 |
> 10 | var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
     | ^
  11 |
  12 | var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
  13 |


  WebpackError: TypeError: _interopRequireDefault is not a function

  - index.js:10
    node_modules/gatsby-link/index.js:10:1

  - utils.js:136
    node_modules/@reach/router/lib/utils.js:136:1

gatsby-link requires babel/runtime/helpers/interopRequireDefault which seems to no longer exist in @babel/runtime@7.13

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 28 (13 by maintainers)

Commits related to this issue

Most upvoted comments

Yes, I’ll start working on this in 10 mins

Oh I think that the reason was that one of your dependency was using @babel/runtime@7.13.0 as a dependency, and by explicitly installing it you forced npm to update it. You can probably remove @babel/runtime from your deps now.

This bug is NOT fixed (as evidenced by the many new issues being opened within the last few hours). It would appear that a LOT of dependencies are pulling in the latest versions of babel automatically which makes it difficult to even temporarily roll back to an earlier babel version (unless you commit a yarn.lock file). Don’t mean to complain–just trying to get the word out that there are still some serious issues unresolved.

@nicolo-ribaudo Example repo with package-lock: https://github.com/AndriusBil/babel-require-example

EDIT: It works with “@babel/runtime”: “7.12.18” and does not work with either “7.13.0” or “7.13.1” or “7.13.2”

I know the problem and the fix, working on the PR.

Babel injects this code:

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Webpack sees this exports map

And replaces it with (because that’s what we are telling it to do)

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault/index.mjs");

Sorry to bother!

I got it fixed, but I had to install npm install --save-dev @babel/runtime to solved it. The strange is that I didn’t need to install it before until today. I don’t know what’s changed.

@nicolo-ribaudo Let me know if you still need to see my Lockfile. @AndriusBil your comment was what made me attempt to install it. Thanks!

I HAVE MET THIS PROBLEM TOO, SOMEBODY HELP ME PLEASE

@nicolo-ribaudo you can use this repo! https://github.com/gillkyle/babel-repro

It’s got even less packages than the default starter if you’re looking for something you can just clone.

I’m getting this error locally when running gatsby build:

failed Building production JavaScript and CSS bundles - 0.973s

 ERROR #98123  WEBPACK

Generating JavaScript bundles failed

Cannot read property 'resolved' of undefined

File: .cache/polyfill-entry.js


 ERROR #98123  WEBPACK

Generating JavaScript bundles failed

Cannot read property 'resolved' of undefined

File: .cache/production-app.js

EDIT: realizing now how useless that output is (besides file paths) 😅