3

I am getting the following error:

ReferenceError: regeneratorRuntime is not defined

and it is caused by

_asyncToGenerator(regeneratorRuntime.mark(function _callee() {

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

My .babelrc is as below

{
  "presets":["latest"]
}

I am able to solve the problem by add require('babel-polyfill') however this line will throw problem if I run it with babel-node during development time.

Anyone faced similar problem before?

drhanlau
  • 2,517
  • 2
  • 24
  • 42
  • To answer your question: Yes, I have experienced this problem with node 8.x with similar results in that when I add `require('babel-polyfill')` the problem goes away, but I shouldn't have to do this. It appears to be environmental. – gavdotnet Sep 12 '17 at 10:36

1 Answers1

1

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

{
  "presets": [["es2016"]],
  "plugins": ["syntax-async-functions","transform-regenerator","babel-polyfill"],
}
Alex
  • 852
  • 1
  • 10
  • 21