4

io.js released 1.0.1 version yesterday and, as the developers say, it's now possible to use classes without a nightly build.

But I'm not able to use ES6 classes without being in the REPL, e.g.:

$ iojs --use_strict --harmony_classes
> class Person {}
> [Function: Person]

But it I write it in a file, it doesn't work:

$ iojs test.js --use_strict --harmony_classes
class Person {}
^^^^^
SyntaxError: Unexpected reserved word
    at exports.runInThisContext (vm.js:54:16)
    at Module._compile (module.js:429:25)
    at Object.Module._extensions..js (module.js:464:10)
    at Module.load (module.js:341:32)
    at Function.Module._load (module.js:296:12)
    at Function.Module.runMain (module.js:487:10)
    at startup (node.js:111:16)
    at node.js:809:3

What am I doing wrong?

Talysson
  • 1,363
  • 1
  • 9
  • 13

1 Answers1

6

The command line arguments are not actually applied to iojs. Change the command to

iojs --use_strict --harmony_classes test.js

it will work fine now.

thefourtheye
  • 233,700
  • 52
  • 457
  • 497