Problem
I’m trying to use async, await APIs with Babel 6, and I’m getting a ‘regeneratorRuntime is not defined’ error. Here below I have added configuration files.
How we can do it without .babelrc (just using webpack config file)?.
Solution
This error is caused when async/await functions are used without the proper Babel plugins. To install @babel/plugin-transform-runtime
by typing in the command line,
npm install --save-dev @babel/plugin-transform-runtime
Then Add the plugin to pakage.json file in plugins
array.
So the final changes of the package.json and webpack.config.dev.js file would be,
package.json
file
Note: We assume that the installed all below-highlighted packages related to babel configurations, otherwise do copy and replace the above configuration code to the package.json file and do run this command npm i
again in the command window.
webpack.config.dev.js
file