senecajs / seneca-web-adapter-koa2

Seneca-web adapter for koa web framework (v2)
MIT License
17 stars 4 forks source link

^ SyntaxError: Unexpected token #7

Closed cnxuyc closed 7 years ago

cnxuyc commented 7 years ago
const Seneca = require('seneca')
const SenecaWeb = require('seneca-web')
const Koa = require('koa')
const Router = require('koa-router')
const app = Koa()
const seneca = Seneca()
seneca.use(SenecaWeb, {
  context: Router(),
  adapter: require('seneca-web-adapter-koa2')
})
seneca.ready(() => {
  app.use(seneca.export('web/context')().routes())
`})`

Run the above code to get an error

context[method.toLowerCase()](route.path, async (ctx, next) => {
                                                      ^
SyntaxError: Unexpected token (
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    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)
    at Object.<anonymous> (C:\Users\Search You\WebstormProjects\node-ms-user\index.js:13:14)
    at Module._compile (module.js:570:32)
tswaters commented 7 years ago

Ya know what - I don't think I ever tried to install this repo after having published it.

The version that is published to npm isn't transpiled, I don't think.

Congratulations, you are the first person to actually install and try the package (and find it not working at all!)

I'll publish a patch to this shortly....

cnxuyc commented 7 years ago

However, I just upgraded to version nodejs 7.6.0, successfully running,i think you package should add es7 async await support。

tswaters commented 7 years ago

I've added the babel transpile which is what the tests run under... this is now published as 1.0.2

Should work with node 4+ now.

tswaters commented 7 years ago

Shoot. I just tried installing it actually and it's not pulling in the lib directory properly.

Back to the npm docs to me... standby.

tswaters commented 7 years ago

Ok, should be working now... I've verified the install and it has all the bits where they need to be.