koa2在node6下运行
{
"babel-core": "^6.24.1",
"babel-plugin-syntax-async-functions": "^6.13.0",
"babel-plugin-transform-async-to-generator": "^6.24.1",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-polyfill": "^6.23.0",
"babel-preset-es2015-node6": "^0.4.0",
"babel-register": "^6.24.1"
}
var babelrc = {
"presets": ["node6"],
"plugins": [
"transform-class-properties",
"transform-async-to-generator"
]
}
require("babel-core/register")(babelrc);
require("./app.js");
koa-bodyparser 报错SyntaxError: Unexpected token function
解决方案:https://github.com/koajs/bodyparser/tree/3.x
koa1使用 npm install koa-bodyparser@2
koa2使用 npm install koa-bodyparser@3
koa-jwt 报错SyntaxError: Unexpected token function
解决方案:https://github.com/koajs/jwt
koa1使用 npm install koa-jwt@1
koa2并且node< 7.6 使用 npm install koa-jwt@2.
koa2并且node>= 7.6 使用 npm install koa-jwt@3.