通过node和nvm获取ES6功能

Mad*_*d0g 10 node.js ecmascript-harmony nvm

我已经有节点0.10.*并且我安装了nvm,然后通过nvm我再次安装了0.11.13和0.10.

node --version返回0.11.13

我尝试使用我读过的一些ES6功能,而我尝试过的任何功能都没有.

我用我的脚本运行 node --harmony index.js

...argsSyntaxError: Unexpected token .

let x = 5; 也给出了错误 - SyntaxError: Unexpected identifier

我在哪里可以找到0.11.13目前支持的内容?

Mri*_*jay 8

试试这个

"use strict"
let x = 5;
console.log(x)
Run Code Online (Sandbox Code Playgroud)

它会工作.

像下面这样运行它

node --harmony file.js
Run Code Online (Sandbox Code Playgroud)

  • 哇.`node --harmony script.js`与`node script.js --harmony`不同 (4认同)
  • @ Madd0g不,绝对不是.你应该把它放在你的问题中.你正在做的是将参数传递给Node.js脚本,而不是传递给Node本身. (2认同)