RegeneratorRuntime not defined for nodeJS transpiled babel

I am getting the following error:

ReferenceError: regeneratorRuntime is not defined

      

and this is caused by

_asyncToGenerator(regeneratorRuntime.mark(function _callee() {

      

I have tried methods in Babel 6 restoreatorRuntime is not defined with async / await , and RegeneratorRuntime is undefined but no luck.

My .babelrc

below

{
  "presets":["latest"]
}

      

I can solve the problem by adding require('babel-polyfill')

, however this line will cause the problem if I run it from babel-node

during development.

Has anyone faced a similar issue before?

+3


source to share


1 answer


Add babel-polyfill to your plugins in your .babelrc file:



{
  "presets": [["es2016"]],
  "plugins": ["syntax-async-functions","transform-regenerator","babel-polyfill"],
}

      

+1


source







All Articles