Module exports in ES6


Frequently asked question these days is how to use module.exports in ES6 style.

The export declaration is used to export values from a JavaScript module.

Default export

module.exports = Car

in ES6:

export default Car

Named export

module.exports.Car = Car

ES6 equivalent:

export { Car }

Then you can import it as usual:

import defaultImport from 'module'


import { someVar } from 'module'