ReferenceError: regeneratorRuntime is not defined (but working inside a scope)

前端 未结 3 1746
借酒劲吻你
借酒劲吻你 2021-02-07 02:53

I\' ve come across this strange occurrence of:

ReferenceError: regeneratorRuntime is not defined

... which I\'ve managed to reproduce in a very minima

3条回答
  •  [愿得一人]
    2021-02-07 03:05

    Also you could do the following with es2015 preset and transform-regenerator plugin:

    .babelrc

    {
      "presets": ["es2015"],
      'plugins': [
        'transform-regenerator'
      ]
    }
    

    Code

    let regeneratorRuntime =  require("regenerator-runtime");
    // You code with ES6 generators
    

    P.S. Of course you should install babel-plugin-transform-regenerator npm package.

提交回复
热议问题