domenic / count-to-6

An intro to some ES6 features via a set of self-guided workshops.
Other
326 stars 76 forks source link

node doesn't know about ES6 features #19

Closed dKab closed 9 years ago

dKab commented 9 years ago

I tried to run this line in my terminal: node -e 'function test(...args) { console.log(args.join(' ')) } test('this' 'is' 'a' 'test');' and I got SyntaxError: Unexpected token . My node version is 0.10.35 , but apparently it doesn't recognize REST feature syntax (the "...args" part) and I'm curious why is that? Given the fact that when I use this syntax to solve count-to-6 workshop tasks it works alright and it runs in the same environment, right? I mean when I run 'count-to-6 verify file.js' it uses nodejs installed on my machine to evaluate the script. Am i missing something here?

domenic commented 9 years ago

I mean when I run 'count-to-6 verify file.js' it uses nodejs installed on my machine to evaluate the script.

Not quite! As we say in the readme,

It leverages the excellent Traceur compiler to allow you to write code with ES6 syntax, today.

That is, before running any Node code, we compile it with Traceur.

You should be able to get a similar experience if you use my Traceur Runner project. npm install -g traceur-runner, then do traceur-runner myscript.js.