未定义Babel 6 regeneratorRuntime

我的梦境 提交于 2020-10-27 03:29:31

问题:

I'm trying to use async, await from scratch on Babel 6, but I'm getting regeneratorRuntime is not defined. 我正在尝试使用异步,在Babel 6上从头开始,但是我得到的regeneratorRuntime尚未定义。

.babelrc file .babelrc文件

{
    "presets": [ "es2015", "stage-0" ]
}

package.json file package.json文件

"devDependencies": {
    "babel-core": "^6.0.20",
    "babel-preset-es2015": "^6.0.15",
    "babel-preset-stage-0": "^6.0.15"
}

.js file .js文件

"use strict";
async function foo() {
  await bar();
}
function bar() { }
exports.default = foo;

Using it normally without the async/await works just fine. 正常使用它而无需异步/等待就可以了。 Any ideas what I'm doing wrong? 有什么想法我做错了吗?


解决方案:

参考一: https://stackoom.com/question/2Gg4b/未定义Babel-regeneratorRuntime
参考二: https://oldbug.net/q/2Gg4b/Babel-6-regeneratorRuntime-is-not-defined
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!