10

I already had node 0.10.* and I installed nvm, then through nvm I installed 0.11.13 and 0.10 again.

node --version gives back 0.11.13

I try to use some of the ES6 features I read about and nothing I tried works.

I run my script with node --harmony index.js

...args says SyntaxError: Unexpected token .

let x = 5; also gives an error - SyntaxError: Unexpected identifier

Where can I find what's currently supported in 0.11.13?

4

2 回答 2

8

试试这个

"use strict"
let x = 5;
console.log(x)

它会起作用的。

像下面一样运行它

node --harmony file.js
于 2014-07-16T03:13:23.753 回答
3

我遇到了同样的问题,发现我以某种方式运行节点 0.12.7(我知道,对吧?!)。升级到最新版本 (5.6.0) 解决了该问题。

于 2016-02-12T18:13:16.027 回答