I\'m trying to use async, await from scratch on Babel 6, but I\'m getting regeneratorRuntime is not defined.
.babelrc file
{
\"presets\": [ \"es2
This error is caused when async/await
functions are used without the proper Babel plugins. As of March 2020, the following should be all you need to do. (@babel/polyfill
and a lot of the accepted solutions have been deprecated in Babel. Read more in the Babel docs.)
In the command line, type:
npm install --save-dev @babel/plugin-transform-runtime
In your babel.config.js
file, add this plugin @babel/plugin-transform-runtime
. Note: The below example includes the other presets and plugins I have for a small React/Node/Express project I worked on recently:
module.exports = {
presets: ['@babel/preset-react', '@babel/preset-env'],
plugins: ['@babel/plugin-proposal-class-properties',
'@babel/plugin-transform-runtime'],
};