I\'m trying to use arrow functions in node v0.10.33
under Ubuntu 14.04
(I\'m running node with --harmony
flag), but I\'m getting this
Node, even with the harmony flag, doesn't support the fat arrow yet. Source.
Edit: Fun little fact, ES6 support is one of the reasons Node got forked into io.js. Check out their page on ES6 features - they provide a flag for the arrow functions, but discourage using it.
This should work now in node v0.12.x, with the --harmony
flag. Also note that you can get arrow functions in node using the babel
package.
http://babeljs.io/docs/using-babel/
UPDATE:
As correctly indicated by Mike 'Pomax' Kamermans, the --harmony
flag is not required when using Node.js >= 4.x. Please see https://nodejs.org/en/docs/es6/ for more information on the status of ES6 support in Node.js.