Wie starte ich eine einfache App mit koa2?

Proble

Ich versuche, einen einfachen http-Server mit @ auszuführe koa2, habe aber Probleme damit.

Es verwendet es6 das wird voraussichtlich in Zukunft funktionieren node.js Versionen und ich habe mich gefragt, wie ich es mit @ ausführen kanode v6.1.0 ?

Cod

import Koa from 'koa';    
const app = new Koa();

// Setup handler.
app.use(async ctx => {
    ctx.body = "Hello World!";
});

// Start server.
app.listen(3000);

Ausgab

$ node --version
v6.1.0

$ node --harmony index.js
C:\Users\gevor\WebstormProjects\untitled1\index.js:1
(function (exports, require, module, __filename, __dirname) { import Koa from 'koa';
                                                              ^^^^^^
SyntaxError: Unexpected token import
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:511:25)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:456:32)
    at tryModuleLoad (module.js:415:12)
    at Function.Module._load (module.js:407:3)
    at Function.Module.runMain (module.js:575:10)
    at startup (node.js:160:18)
    at node.js:445:3

Frag

Ich möchte wissen, wie meine App ausgeführt wird.

Ähnliche Probleme

https: //github.com/koajs/koa/issues/62https: //github.com/koajs/koa/issues/57

Antworten auf die Frage(4)

Ihre Antwort auf die Frage