ReactJS ReferenceError: regeneratorRuntime is not defined

Dung Do Tien Nov 30 2021 807

Hello, I have created a project with Nodejs and ReactJS. 

when running the application with the command npm run/build I get an exception throw ReferenceError: regeneratorRuntime is not defined.

Uncaught ReferenceError: 
  regeneratorRuntime is not defined
      at _requestPets (FillterModel.js:8)
      at requestPets (FillterModel.js:8)
      at FillterModel.js:26
      at invokePassiveEffectCreate (react-dom.development.js:23487)
      at HTMLUnknownElement.callCallback (react-dom.development.js:3945)
      at Object.InvokeGuardedCallbackDev (react-dom.development.js:3994)

My .babelrc

    "presets": [    [
        "@babel/preset-env", {
          "targets": {
            "node": "current"
      ], "@babel/preset-react"],
    "plugins": [

I'm using Node v12.18.3, Npm 6.14.6, and Babel 7

Thanks for any solutions.

Have 3 answer(s) found.
  • L

    Linh Mai Nov 30 2021

    In Babel 7 you need to install two packages are:

    npm install --save @babel/runtime 
    npm install --save-dev @babel/plugin-transform-runtime

    And add more .babelrc like this:

        "presets": ["@babel/preset-env"],
        "plugins": [
              "regenerator": true       

    Hope it is helpful for you.

  • b

    bouhlel ahmed Nov 30 2021

    1. You need to install regenerator-runtime

    npm install --save regenerator-runtime

    2. Update  your webpack file

    entry: ["regenerator-runtime/runtime.js", "<your enter js file>"]

    For example: 

    module.exports = {
      entry: ['regenerator-runtime/runtime.js', './test.js']

    3. Import import 'regenerator-runtime/runtime'  at the top of the file, you got an error.

  • t

    trusted flirter Nov 30 2021

    I got the same error and I changed my .babelrc file as below:

    module.exports = {
      presets: [
            targets: {
              esmodules: true,

    And it worked for me.

Leave An Answer
* NOTE: You need Login before leave an answer

* Type maximum 2000 characters.

* All comments have to wait approved before display.

* Please polite comment and respect questions and answers of others.

Popular Tips

X Close