Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting ES6 features with node and nvm

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?

like image 721
Madd0g Avatar asked Jul 16 '14 03:07

Madd0g


2 Answers

Try this instead

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

It will work.

run it like following

node --harmony file.js
like image 138
Mritunjay Avatar answered Nov 15 '22 23:11

Mritunjay


I had this same issue and found that I was somehow running node 0.12.7 (I know, right?!). Upgrading to the latest (5.6.0) resolved the issue.

like image 21
Phil Avatar answered Nov 16 '22 01:11

Phil