I have an ES6 class which I am trying to export as a module, however I am getting an error SyntaxError: Unexpected reserved word
Car.js
class Car {
constructor(make) {
this.make = make;
this.currentSpeed = 25;
}
printCurrentSpeed(){
console.log(this.make + ' is going ' + this.currentSpeed + ' mph.');
}
}
module.exports = Car;
I am trying to use the Car module like this
main.js
var Car = require("./models/Car");
let must = new Car('Mustang');
console.log(must.printCurrentSpeed());
I am using browserify with babelify to transform to ES6
browserify -t babelify main.js -o public/scripts/bundle.js",
Am I exporting the Car module correctly, or am I doing something wrong?