{"id":575,"hash":"234afa6cdcf4be82b8b7b06f6a3f6202bd96466541fc79f1045866a7c2e60406","pattern":"Babel 7 - ReferenceError: regeneratorRuntime is not defined","full_message":"I have an application that is a node backend and a react frontend.\n\nI get the following error when i try to build/run my node application.\n\nNode: v10.13.0\n\nError:\n\n  dist/index.js:314\n        regeneratorRuntime.mark(function _callee(productId) {\n        ^\n\n  \n  ReferenceError: regeneratorRuntime is not defined\n\n.babelrc\n\n{\n    \"presets\": [    [\n        \"@babel/preset-env\", {\n          \"targets\": {\n            \"node\": \"current\"\n          },\n        }\n      ], \"@babel/preset-react\"],\n    \"plugins\": [\n        \"@babel/plugin-proposal-class-properties\"\n    ]\n}\n\nwebpack.config.js\n\n{\n        mode: \"development\",\n        entry: \"./src/index.js\",\n        target: \"node\",\n        externals: [nodeExternals()], // in order to ignore all modules in node_modules folder\n        stats: {\n            colors: true\n        },\n        devtool: \"source-map\",\n\n        output: {\n            path: path.resolve(__dirname, \"dist\"),\n            filename: \"index.js\",\n            sourceMapFilename: \"index.js.map\"\n        },\n        module: {\n            rules: [\n                {\n                    enforce: \"pre\",\n                    test: /\\.js$/,\n                    exclude: /node_modules/,\n                    loader: \"eslint-loader\",\n                },\n                {\n                    test: /\\.m?js$/,\n                    exclude: /(node_modules|bower_components)/,\n                    use: {\n                        loader: \"babel-loader\",\n                        options: {\n                            presets: [\"@babel/preset-env\"]\n                        }\n                    }\n                }\n            ],\n        },\n        node: {\n            __dirname: false,\n            __filename: false,\n        },\n\n        \"plugins\": [\n            new CleanWebpackPlugin(),\n            new WebpackShellPlugin({\n                onBuildStart: [],\n                onBuildEnd: [\"nodemon dist/index.js\"]\n            }),\n\n        ]\n\n    },\n\npackage.json\n\n \"dependencies\": {\n    \"connect\": \"^3.6.6\",\n    \"cors\": \"^2.8.5\",\n    \"dotenv\": \"^6.1.0\",\n    \"express\": \"^4.16.4\",\n    \"hellojs\": \"^1.17.1\",\n    \"i18n-iso-countries\": \"^3.7.8\",\n    \"morgan\": \"^1.9.1\",\n    \"react\": \"^16.6.3\",\n    \"react-dom\": \"^16.6.3\",\n    \"request\": \"^2.88.0\",\n    \"request-promise-native\": \"^1.0.5\",\n    \"serve-static\": \"^1.13.2\",\n    \"vhost\": \"^3.0.2\"\n  },\n  \"devDependencies\": {\n    \"@babel/cli\": \"^7.1.5\",\n    \"@babel/core\": \"^7.1.6\",\n    \"@babel/plugin-proposal-class-properties\": \"^7.1.0\",\n    \"@babel/preset-env\": \"^7.1.6\",\n    \"@babel/preset-react\": \"^7.0.0\",\n    \"babel-eslint\": \"^10.0.1\",\n    \"babel-loader\": \"^8.0.4\",\n    \"clean-webpack-plugin\": \"^1.0.0\",\n    \"copy-webpack-plugin\": \"^4.6.0\",\n    \"css-loader\": \"^1.0.1\",\n    \"eslint\": \"^5.9.0\",\n    \"eslint-config-google\": \"^0.10.0\",\n    \"eslint-loader\": \"^2.1.1\",\n    \"eslint-plugin-react\": \"^7.11.1\",\n    \"extract-loader\": \"^3.0.0\",\n    \"file-loader\": \"^2.0.0\",\n    \"node-sass\": \"^4.10.0\",\n    \"sass-loader\": \"^7.1.0\",\n    \"style-loader\": \"^0.23.1\",\n    \"webpack\": \"^4.26.0\",\n    \"webpack-cli\": \"^3.1.2\",\n    \"webpack-node-externals\": \"^1.7.2\",\n    \"webpack-shell-plugin\": \"^0.5.0\"\n  }","ecosystem":"npm","package_name":"node.js","package_version":null,"solution":"Updated Answer:\n\nIf you are using Babel 7.4.0 or newer, then @babel/polyfill has been deprecated. Instead, you will want to use the following at the top of your main js file (likely index.js or similar):\n\nimport \"core-js/stable\";\nimport \"regenerator-runtime/runtime\";\n\nInstall these packages either with npm:\n\nnpm install --save core-js\nnpm install --save regenerator-runtime    \n\nor with yarn:\n\nyarn add core-js\nyarn add regenerator-runtime\n\nOriginal Answer:\n\nI just encountered this problem and came across the following solution:\n\nIn package.json I had @babel/polyfill as a dependency. However, in my index.js (My main js file) I had neglected to place the following line at the the top:\n\nimport '@babel/polyfill'\n\nOnce I imported it, everything worked fine.\n\nI did not need to install babel-runtime as other answers are suggesting.","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/53558916/babel-7-referenceerror-regeneratorruntime-is-not-defined","votes":109,"created_at":"2026-04-19T04:51:22.572468+00:00","updated_at":"2026-04-19T04:51:22.572468+00:00"}