问题:
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
来源:oschina
链接:https://my.oschina.net/stackoom/blog/4281270