Using Node.js require vs. ES6 import/export
@lebyy▲ 0 net votes
Problem: In a project I am collaborating on, we have two choices on which module system we can use: Importing modules using require , and exporting using module.exports and exports.foo . Importing modules using ES6 import , and exporting using ES6 export Are there… Fix (from the top answer): Update Since Node.js v12 (April 2019), support for ES modules is enabled by default, and since Node.js v15 (October 2020) it's stable (see here ). Files, including Node.js modules, must either end in .mjs or the nearest package.json file must contain "type": "module" . The Node.js documentation has a ton more…