babel-polyfill配置:ReferenceError: regeneratorRuntime is not defined
Author:zhoulujun Date:
ReferenceError: regeneratorRuntime is not defined 错误,无法编辑
原因是,使用了es7 es8 等语法。比如aysnc await ,就会报这个错。原因是,bable 编译出错,缺少ES7的babel转译
即使.babelrc配置了
"plugins": [ [ "transform-runtime", { "helpers": false, "polyfill": false, "regenerator": true, "moduleName": "babel-runtime" } ]]
还是会报错
解决之道,要么在首页入口增加
import "babel-polyfill"
或者在webpack 入口里面配置
entry: {//配置页面入口 index: ['babel-polyfill', './src/index.js'] },
我推荐在webpack里面配置
当然,需要npm install --save-dev babel-polyfill
不知道道友们,还有无其它更好的办法,请留言分享。
转载本站文章《babel-polyfill配置:ReferenceError: regeneratorRuntime is not defined》,
请注明出处:https://www.zhoulujun.cn/html/tools/Bundler/webpack/2018_0131_8383.html
延伸阅读:
- webpack4.x 升级react-router v4 发现history 冲突
- webpack4.x 与react-router2.x冲突,报错
- DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` inste
- Can't resolve 'react-dom/lib/ReactTestUtils' in 'react-addons-test-utils'
- webpack外网访问设置—webpack-dev-server配置及跨域解决
- webpack编译sass,缺少vendor, node-sass报 vendor错误
- webpack css背景图片无法现实,图片路径404
- webpack scripts copyfiles copy图片至dist目录
- webpack一直报Invalid Host header
- webpack执行终端shell命令操作系统:webpack-shell-plugin
- webpack4循环依赖:UnhandledPromiseRejectionWarning: Error: Cyclic dependency
- vue-cli导出webpack配置给webstorm/intellij,从而智能提示
- UglifyJs配合webpack打包报Unexpected token: keyword const
- webpack+eslint全局变量设置
- webpack抽离css,mini-css-extract-plugin Conflicting order
- webpack打包之文件Gzip压缩与Brotli压缩配置
- TS1259+TS6142: Module can only be default-imported using the 'esModuleInterop
- dart-sass替代node-sass区别:fix Node Sass一切问题(系统不支持/gyp
- webpack配置devServer配置https代理与证书
- webpack打包发布npm包优化-vue/echarts等公共库抽离
- webpack打包npm组件库,libraryTarget如何选择?
- webpack 开环境 资源查看webpack-DEV-SERVER
- Critical dependency: the request of a dependency is an expression
- webpack打包vue组件与JS-SDK注意事项
- webpack动态路径:__webpack_public_path__作用