Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Share On Stumbleupon
Contact us
Hide Buttons

exports is not defined

This is very com­mon error when your project has ES6 mod­ules as well as require.js mod­ule sys­tems. Here, I will show you few exam­ples on how to require ES6 mod­ules inside an AMD mod­ule. It will help you mit­i­gate such errors.

default export

// Employee.js

function Employee () {
 ...
}

export default new Employee();

// HR.js

var Employee = require('Employee').default;

named export

// Employee.js

function Employee () {
 ...
}

export const employee = new Employee();

// HR.js

var Employee = require('Employee').employee;

default is also a named export, with its name being default.



You may also like...