在浏览器中使用Babel透明ES6生成器

时间:2016-09-01 19:54:33

标签: javascript ecmascript-6 babel babel-cli

我能够用babel转换ES6,但是当我尝试测试生成器时,我得到了这个例外。 Uncaught ReferenceError: regeneratorRuntime is not defined

我环顾四周,发现我必须添加bable-generator和运行时插件。我从package.json中可以看到我添加了它们但仍然出现此错误。

我正在运行babel cli" npm run watch"它编译我的代码,我可以在浏览器中运行它。我有一种感觉,我错过了一步:)

{
  "devDependencies": {
    "babel-cli": "^6.14.0",
    "babel-plugin-transform-regenerator": "^6.14.0",
    "babel-plugin-transform-runtime": "^6.15.0",
    "babel-preset-es2015": "^6.14.0"
  },
  "scripts": {
    "build": "babel src -d output",
    "watch": "babel src --watch -d output"
  },
  "dependencies": {
    "babel-polyfill": "^6.13.0",
    "babel-runtime": "^6.11.6"
  }
}

{
  "presets": ["es2015"]
}

0 个答案:

没有答案