Babel 6 不转译我的代码

Babel 6 doesn't transpile my code

这是我的代码

require('babel-register')
require('babel-polyfill')

const Koa = require('koa');
const app = new Koa();

// logger

app.use(async (ctx, next) => {
  const start = new Date;
  await next();
  const ms = new Date - start;
  console.log(`${ctx.method} ${ctx.url} - ${ms}ms`);
});

// response

app.use(ctx => {
  ctx.body = 'Hello World';
});

app.listen(3000);

Koa v2.0 使用async/await 的例子。不幸的是它不起作用。我收到以下错误:

app.use(async (ctx, next) => {
SyntaxError: Unexpected token (

这里是package.json

{
  "name": "app",
  "version": "0.0.1",
  "scripts": {
    "start": "node index"
  },
  "dependencies": {
    "koa": "^2.0.0-alpha.3"
  },
  "devDependencies": {
    "babel-plugin-transform-async-to-generator": "^6.3.13",
    "babel-polyfill": "^6.3.14",
    "babel-preset-stage-0": "^6.3.13",
    "babel-register": "^6.3.13",
    "eslint": "^1.10.3"
  }
}

这是我的.babelrc

{
  "presets": ["stage-0"],
  "plugins": ["transform-async-to-generator"]
}

已解决。它还需要包含 es2015 预设并将挂钩移动到另一个文件