在项目中使用async/await
的语法后,终端编译报错
regeneratorRuntime is not defined
原因
webpack
编译并没有把ES6/7/8/9/10
的部分新特性编译为ES5
此处是没有经过transform-runtime
编译,需要安装插件
下载依赖
npm i babel-plugin-transform-runtime -D
配置文件
文件为.babelrc
"plugins": [
"transform-runtime"
]
Tips
语法相关的优先排查babel
配置
也可以通过配置babel-polyfill