[英]regeneratorRuntime is not defined for nodeJS transpiled babel
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. 我已经尝试过Babel 6中的方法.RentimeRuntime没有用async / await 定义 ,也没有定义RegeneratorRuntime ,但没有运气。
My .babelrc
is as below 我的.babelrc
如下
{
"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. 我可以通过添加require('babel-polyfill')
来解决这个问题,但是如果我在开发期间使用babel-node
运行它,这行会引发问题。
Anyone faced similar problem before? 以前有人遇到类似问题吗?
Add babel-polyfill to your plugins in the .babelrc file: 将babel-polyfill添加到.babelrc文件中的插件中:
{
"presets": [["es2016"]],
"plugins": ["syntax-async-functions","transform-regenerator","babel-polyfill"],
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.