Heim  >  Fragen und Antworten  >  Hauptteil

koa2 – node.js koa ctx=> Fehlerbericht

Ich habe gerade angefangen, Koa zu kontaktieren, und es wird immer wieder angezeigt, dass es nicht funktioniert. Bitte helfen Sie mir => {

         ^

SyntaxError: Unerwartetes Token >

at exports.runInThisContext (vm.js:69:16)
at Module._compile (module.js:432:25)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:349:32)
at Function.Module._load (module.js:305:12)
at Function.Module.runMain (module.js:490:10)
at startup (node.js:124:16)
at node.js:803:3

Dies ist der Quellcode

const Koa = require('koa');

const app = new Koa();

app.use(ctx => {

ctx.body = 'Hallo Koa';

});

app.listen(3000);

console.log('App wurde an Port 3000 gestartet....');

阿神阿神2688 Tage vor621

Antworte allen(2)Ich werde antworten

  • 習慣沉默

    習慣沉默2017-05-16 13:35:32

    记得koajs2应该是

    app.use(async (ctx, next) => { await next(); });

    另外检查一下nodejs的版本是不是太低了

    Antwort
    0
  • 天蓬老师

    天蓬老师2017-05-16 13:35:32

    找到原因了 果然node.js 版本太低了 谢谢一楼

    Antwort
    0
  • StornierenAntwort