I
I
Ily4farmer2021-02-25 01:16:20
gulp.js
Ily4farmer, 2021-02-25 01:16:20

Why does gulp-webpack build stop working when using async/await?

Made a Gulp+Webpack build.
Started writing a module using async/await

const asyncAwait = () => {
    const url = 'https://api.github.com/repos/javascript-tutorial/en.javascript.info/commits';
    const url2 = 'https://api.github.com/users';

    async function getUser() {
        let commits = await fetch(url);
        console.log(commits);
    }
    getUser();
}
module.exports = asyncAwait;

And the error
Uncaught ReferenceError: regeneratorRuntime is not defined
at n (script.js:1)
at script.js:1
at t.exports (script.js:1)
at HTMLDocument starts popping up in the browser. (script.js:1)
How to fix the error?

Here is the webpack.config code:
module.exports = {
    mode: process.env.NODE_ENV,
    //development production
      mode: 'development', 
      output: {
        filename: 'script.js',
      },
      module: {
        rules: [
          {
            test: /\.m?js$/,
            exclude: /(node_modules|bower_components)/,
            use: {
              loader: 'babel-loader',
              options: {
                presets: ['@babel/preset-env']
                
              }
            }
          }
        ]
      },
  };

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Makhov, 2021-02-25
@Ily4farmer

Here is the solution: https://stackoverflow.com/a/36821986/6912339

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question