Node.js ES6如何从模块中导出类?

我试图从Node.js 6.2.0中的CommonJS模块中导出一个ES6类

class MyClass{ //class contents here } exports = MyClass; 

然后将其导入另一个模块中:

 var MyClass = require('/path/to/module.js') var instance = new MyClass(); 

但是,我收到以下exception:

 TypeError: MyClass is not a constructor 

我该如何正确地做到这一点?

请注意,我没有使用Babel / Tranceur,它是纯粹的JS,在最新的Node 6.2.0中实现,根据Kangax,93%实现了ES6。

//编辑:这不是出口vs module.exports的问题。 单独使用导出时,我得到一些与__proto__设置的对象。

您将需要分配给module.exports ,而不是本地exportsvariables。