node版本是
v6.2.2
新建一个
app.js
内容如下
async function responseTime(ctx, next) {
const start = new Date();
await next();
const ms = new Date() - start;
ctx.set('X-Response-Time', `${ms}ms`);
然后node app.js
报如下错误:
mbp:hybrid-statistic wfp$ node app.js
/Users/wfp/Work/hybrid-statistic/app.js:28
async function responseTime(ctx, next) {
^^^^^^^^
SyntaxError: Unexpected token function
at Object.exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:513:28)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)