0

I am able to run ES6 features like let, const, arrow functions in node 0.12.7 version using --harmony option, but classes and string templates do not work.

for example: UserErrors.js:

'use strict';

class UserNotFoundError extends Error {
    constructor(id) {
        super('User with id ' + id + ' not found.');
        this.id = id;
    } 
}

module.exports = {
    UserNotFoundError: UserNotFoundError
};

I get following error:

Unhandled rejection C:\<Path>\SecurityAPI\modules\v2\user\UserErrors.js:3
class UserNotFoundError extends Error {
^^^^^

Also tried template string and I get Unexpected token ILLEGAL error:

let id=1234;
let message = `User with id: $(id} not found.`;

Error:

let message = `User with id: $(id} not found.`;
              ^
SyntaxError: Unexpected token ILLEGAL



Node Platform:

I am running Node 0.12.7 through nvm in a windows machine in harmondy mode:

node --harmony server.js
Rohan
  • 665
  • 9
  • 17

0 Answers0