koa2 - node.js koa ctx=> error report
阿神
阿神 2017-05-16 13:33:32
0
2
683

I just started to contact koa and it keeps prompting ctx=> This> error cannot be run. I can’t figure it out and can’t find the information. Please help me.
This is an error.
app.use(ctx => {

         ^

SyntaxError: Unexpected 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

This is the source code
const Koa = require('koa');
const app = new Koa();

app.use(ctx => {
ctx.body = 'Hello Koa';
});

app.listen(3000);

console.log('app started at port 3000....');

阿神
阿神

闭关修行中......

reply all(2)
習慣沉默

Rememberkoajs2should be

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

Also check if the nodejs version is too low

Peter_Zhu

I found the reason. Sure enough, the node.js version is too low. Thank you, first floor

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template