koajs / bodyparser

Koa body parsing middleware
MIT License
1.31k stars 116 forks source link

Unexpected token `function` #77

Closed evgeniysharapov closed 7 years ago

evgeniysharapov commented 7 years ago

I wanted to use this middleware in the ES7 based Javascript app, I get following error

esharapov/koa-es7-test/node_modules/koa-bodyparser/index.js:72
  return async function bodyParser(ctx, next) {
               ^^^^^^^^
SyntaxError: Unexpected token function
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:542:28)
    at Module._extensions..js (module.js:579:10)
    at Object.require.extensions.(anonymous function) [as .js] (/home/esharapov/koa-es7-test/node_modules/babel-register/lib/node.js:152:7)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)

is it an issue with my setup, babel or bodyparser ?

dead-horse commented 7 years ago

if your node is <7.6.0, please use babel with this configuration