babel/preset-env ReferenceError : regeneratorRuntime is not defined

> react-ssr@1.0.0 start /home/lmx/Workspace/react-ssr
> node ./build/bundle.js

webpack:///./src/index.js?:18
  regeneratorRuntime.mark(function _callee(ctx) {
  ^

ReferenceError: regeneratorRuntime is not defined
    at eval (webpack:///./src/index.js?:18:3)
    at eval (webpack:///./src/index.js?:36:2)
    at Object../src/index.js (/home/lmx/Workspace/react-ssr/build/bundle.js:96:1)
    at __webpack_require__ (/home/lmx/Workspace/react-ssr/build/bundle.js:20:30)
    at /home/lmx/Workspace/react-ssr/build/bundle.js:84:18
    at Object.<anonymous> (/home/lmx/Workspace/react-ssr/build/bundle.js:87:10)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-ssr@1.0.0 start: `node ./build/bundle.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-ssr@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

包含 transform-regenerator 插件是因为定义了预设支持的所有浏览器的最后两个版本。

presets: ['@babel/preset-react', ['@babel/preset-env', {
    targets:{
        browsers: ['last 2 versions']
    }
}]]

如果想要解决这个问题,可以在项目的入口文件的顶部引入 babel-polyfill 包即可。

require("babel-polyfill")

记得在引入前,先安装一下依赖

npm install babel-polyfill --save-dev

参考:babel-preset-env@issues/112

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值