koa2 – node.js koa ctx=> Fehlerbericht
阿神
阿神 2017-05-16 13:33:32
0
2
623

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....');

阿神
阿神

闭关修行中......

Antworte allen(2)
習慣沉默

记得koajs2应该是

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

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

Peter_Zhu

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

Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!