Friday 21 April 2017

Node.js - SyntaxError: Unexpected token import while running on node 6.10.2

I am running node version 6.10.2 I am trying to run this peice of code

import * as events from "events"
class MyClass extends events.EventEmitter {
    constructor(x, y){
        this.x = x;
        this.y = y;
    }
    compute(){
        return this.x * this.y;
    }
}
var vow = new MyClass(2,3);
vow.compute();

I am getting this error, How can I make it run?

SyntaxError: Unexpected token import



via marvel308

No comments:

Post a Comment