SyntaxError: Unexpected reserved word when exporting a class in Node v4.0.0
I have started using Node 4 and implemented a simple class:
"use strict";
class AspectType {
// ....
};
export default AspectType;
But I get an error message:
SyntaxError: Unexpected reserved word
I have followed recommendations made in a StackOverflow question: http://stackoverflow.com/questions/32657516/how-to-export-a-es6-class-properly-in-node-4
It looks like a bug to me, or what am I doing wrong? My node version is: v4.0.0.
Yes, you would need to use module.exports = AspectType for now as ES6 modules are not currently implemented
Going to go ahead and close as this isn't directly actionable.
=[ whyyy ??
where would one use module.exports? I've done a project search and that line comes up around 200 times...
@kamin12
The object module.exports is what will be returned when someone requires your project.
A short hand for the object is simply exports
The object is created by mode for every file, but you can overwrite it.
Many people do exports.someFunction to export individual functions.
Whatever object module.exports is referring to is what will be returned