webpack4 打包报错 :regeneratorRuntime is not defined

时间:2023-03-09 18:53:10
webpack4 打包报错 :regeneratorRuntime is not defined

使用async函数,在webpack打包时报错

babel-polyfill is required. You must also install it in order to get async/await working.

需要加入babel-polyfill

npm i -D babel-polyfill

这里有个小插曲,经测试发现yarn 无法安装css-loader 1.0.0,

而且若先用npm安装完css-loader后用yarn安装其他包也会报错,可用npm安装

在webpack.config.js 的entry选项中

 entry: ['babel-polyfill',join("./src/main.js")],

参考链接:https://*.com/questions/33527653/babel-6-regeneratorruntime-is-not-defined