Uncaught ReferenceError: regeneratorRuntime is not defined

Versions

nuxt: 2.15.1
node: 15.8.0

Reproduction
Make a new project and try to run it as dev mode.

Steps to reproduce
See above

What is Expected?
It should start an application from scratch without any kind of errors.

What is actually happening?
I’ve got followed all possible tips that I’ve found here on github. I’ve already installed babel-plugin-transform-regenerator but even so this error does not disappear. I’ve started a new application from scratch using yarn create nuxt-app ... and nothing works. I’m using Fedora 33, Node v15.8.0 and nuxt v2.15.1 (I’ve removed nuxt from package.json and reinstalled again).

image

1 possible answer(s) on “Uncaught ReferenceError: regeneratorRuntime is not defined

    1. Install dependencies
    npm i -D @babel/preset-env
    npm i @babel/plugin-transform-runtime
    npm i @babel/runtime
    1. Nuxt config file
    // nuxt.config.js
    export default {
      ...
    
      // Build Configuration: https://go.nuxtjs.dev/config-build
      build: {
        babel: {
          presets(env, [preset, options]) {
            return [["@babel/preset-env", {}]];
          },
          plugins: [
            [
              "@babel/plugin-transform-runtime",
              {
                regenerator: true
              }
            ]
          ]
        }
      }
    };
    1. Re run Nuxt app
    npm run dev

Uncaught ReferenceError: regeneratorRuntime is not defined

🐛 bug report

When I started using generators in my code. I got the error message when running : Uncaught ReferenceError: regeneratorRuntime is not defined.

🎛 Configuration (.babelrc, package.json, cli command)

{
  "plugins": [
    ["@babel/plugin-transform-runtime", {
      "corejs": 2
    }]
  ]
}
  "devDependencies": {
    "babel-cli": "^7.0.0-beta.3",
    "babel-core": "^7.0.0-beta.3",
    "babel-plugin-transform-class-properties": "^7.0.0-beta.3",
    "babel-plugin-transform-object-assign": "^7.0.0-beta.3",
    "babel-plugin-transform-runtime": "^7.0.0-beta.3",
    "babel-preset-es2015": "^7.0.0-beta.3",
    "babel-preset-react": "^7.0.0-beta.3",
    "babel-preset-stage-0": "^7.0.0-beta.3",
    "babel-runtime": "^7.0.0-beta.3",
    "babelify": "^7.3.0",
    "parcel-bundler": "^1.10.3",
    "qunitjs": "^1.20.0"
  },
  "dependencies": {
    "babel-polyfill": "^7.0.0-beta.3"
  }

🤔 Expected Behavior

generator should just work.

😯 Current Behavior

Uncaught ReferenceError: regeneratorRuntime is not defined
    at Object.parcelRequire.../src/index.js../helpers (index.js:4)
    at newRequire (test.e31bb0bc.js:49)
    at localRequire (test.e31bb0bc.js:55)
    at Object.parcelRequire.graph-edge-traversal.specs.js.qunitjs (graph-edge-traversal.specs.js:2)
    at newRequire (test.e31bb0bc.js:49)
    at localRequire (test.e31bb0bc.js:55)
    at Object.parcelRequire.index.js../graph-edge-traversal.specs (index.js:1)
    at newRequire (test.e31bb0bc.js:49)
    at parcelRequire.../node_modules/process/browser.js (test.e31bb0bc.js:81)
    at test.e31bb0bc.js:107

💁 Possible Solution

This is related to #1762. However, adding import "babel-polyfill" in my index.js made it work. I however cannot do that, I bundle with rollup and that breaks my rollup bundle.

🔦 Context

💻 Code Sample

Cf. test directory
Cf. package.json

🌍 Your Environment

    "babel-runtime": "^7.0.0-beta.3",
    "parcel-bundler": "^1.10.3",
Software Version(s)
Parcel 1.10.3
Node 8.2.0
npm/Yarn npm
Operating System windows 10

7 thoughts on “Uncaught ReferenceError: regeneratorRuntime is not defined

  1. how to solve ?

    If you are targeting modern browsers, a simple solution is to add the browserslist property to your package.json file

    {
        "name": "my-app",
        ...
        "browserslist": [
            "last 1 Chrome versions"
        ],
        ...
    }

    Note: you can change last 1 to last 2 or 3 or however far back you decide to go

  2. how to solve ?

    If you are targeting modern browsers, a simple solution is to add the browserslist property to your package.json file

    {
        "name": "my-app",
        ...
        "browserslist": [
            "last 1 Chrome versions"
        ],
        ...
    }

    Note: you can change last 1 to last 2 or 3 or however far back you decide to go

    Hey! I did it, but still the issue.

  3. Add to your package.json "browserslist": [ "last 2 Chrome versions" ]

    you can change the browser you’re using, It doesn’t have to be only chrome