NodeJS控制台SyntaxError:生成器的意外令牌*

Apa*_*ear 5 javascript generator node.js

我正在运行NodeJS控制台:

$ node --version
v0.12.0
Run Code Online (Sandbox Code Playgroud)

我正在尝试实现像这样的Generator功能

function* colorGen() {
    var colors = ["red", "green", "blue", "white"]
    var i = 0;
    yield colors[i];
    i += 1;
    if (i > 3) {i = 0;}  
}
Run Code Online (Sandbox Code Playgroud)

但是当我运行第一行时,我收到语法错误:

$ node
> function* colorGen() {
SyntaxError: Unexpected token *
    at Object.exports.createScript (vm.js:44:10)
    at REPLServer.defaultEval (repl.js:117:23)
    at bound (domain.js:254:14)
    at REPLServer.runBound [as eval] (domain.js:267:12)
    at REPLServer.<anonymous> (repl.js:279:12)
    at REPLServer.emit (events.js:107:17)
    at REPLServer.Interface._onLine (readline.js:214:10)
    at REPLServer.Interface._line (readline.js:553:8)
    at REPLServer.Interface._ttyWrite (readline.js:830:14)
    at ReadStream.onkeypress (readline.js:109:10)
> 
Run Code Online (Sandbox Code Playgroud)

为什么会这样?

Bar*_*ski 10

生成器函数当前在标志后面的节点中可用--harmony_generators.请参阅V8中实现的功能和节点中的可用功能.