koajs / koa

Expressive middleware for node.js using ES2017 async functions
https://koajs.com
MIT License
35.21k stars 3.23k forks source link

SyntaxError: Unexpected token * #179

Closed wlepinski closed 10 years ago

wlepinski commented 10 years ago

Hi. I'm trying to follow the starter guide and I'm get the following error:

var koa = require('koa');
var app = koa();

app.use(function *(){
  this.body = 'Hello World';
});

app.listen(3000);
SyntaxError: Unexpected token *
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:902:3

I'm using node 0.10.24 and executing the script using node --harmony

slaskis commented 10 years ago

You might want to read https://github.com/koajs/koa#installation again.

You need node 0.11.9+ to use node --harmony but you can use node 0.10.x is you use gnode.

likidu commented 10 years ago

Hi, I'm still getting the same error even it's been running on node 0.11.9. Could you give some hints?

haoxins commented 10 years ago

run with 'node --harmony app.js',not 'node app.js'

likidu commented 10 years ago

Thank you! Now it works pretty well!

wlepinski commented 10 years ago

Do you guys have any tips on how to install unstable versions of NodeJS? Do I have to compile it from source?

hallas commented 10 years ago

@wlepinski use nvm https://github.com/creationix/nvm

wlepinski commented 10 years ago

Forget about it. Just found the installer. http://blog.nodejs.org/2013/12/31/node-v0-11-10-unstable/ Tks.

Thomasdezeeuw commented 10 years ago

Also an easy way to install Node version is N: https://github.com/visionmedia/n.