Skip to content Skip to sidebar Skip to footer

Can We Use `export Default` And `module.exports` At Same Time?

How to use export default and module.exports in the same file. /******** Exports ********/ export default function () { ... }; module.exports = { A, B, C }; How to im

Solution 1:

Pretty sure it's not possible - a default export is basically the same thing as the object (or other expression) you assign to module.exports. Better to use just one syntax style (module.exports or export) consistently. If you're looking to export a default and export other things as well, consider using named exports instead, with export syntax:

// define A, B, Cexportdefaultfunction() { ... };
export { A, B, C };

and import with, for example

import fn, { A } from'./module';

Post a Comment for "Can We Use `export Default` And `module.exports` At Same Time?"