Skip to content

[Bug] Console error: Uncaught TypeError: Cannot set properties of undefined (setting 'default') #14628

@gongshun

Description

@gongshun

💻

  • Would you like to work on a fix?

How are you using Babel?

Other (Next.js, Gatsby, vue-cli, ...)

Input code

same as https://ask.dcloud.net.cn/question/145538.

I wrote async/await in the project created by vue-cli v4.5.17

Configuration file name

babel.config.json

Configuration

No response

Current and expected behavior

Console error: Uncaught TypeError: Cannot set properties of undefined (setting 'default'),Then I click on the error to view the source code,I saw the code below:

// node_modules/@babel/runtime/helpers/esm/regeneratorRuntime.js 
_regeneratorRuntime = function _regeneratorRuntime() {
    return exports;
};
QQ20220601-163039-HD.mp4

Environment

System:
OS: macOS 12.4
Binaries:
Node: 10.24.1 - ~/.nvm/versions/node/v10.24.1/bin/node
Yarn: 1.22.18 - ~/.nvm/versions/node/v10.24.1/bin/yarn
npm: 6.14.12 - ~/.nvm/versions/node/v10.24.1/bin/npm
npmPackages:
@babel/plugin-transform-modules-commonjs: ^7.7.5 => 7.18.2
babel-eslint: ^10.1.0 => 10.1.0
babel-plugin-import: 1.13.3 => 1.13.3
eslint: ^6.7.2 => 6.8.0

Possible solution

When I moved the code that reported the error below, it worked fine,like this:

// node_modules/@babel/runtime/helpers/esm/regeneratorRuntime.js 
 var exports = {},
      Op = Object.prototype,
      hasOwn = Op.hasOwnProperty,
      $Symbol = "function" == typeof Symbol ? Symbol : {},
      iteratorSymbol = $Symbol.iterator || "@@iterator",
      asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
      toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";

_regeneratorRuntime = function _regeneratorRuntime() {
     return exports;
};
QQ20220601-163301-HD.mp4

Additional context

it works normally when I use @babel/runtime v7.17.9

Metadata

Metadata

Assignees

No one assigned

    Labels

    i: questioni: third partyThe report is a problem of third partyoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions