Using ECMAScript modules
ECMAScript is the language specification created to standardize JavaScript, defined by ECMAScript International. ECMAScript modules are the official format to package JavaScript code for reuse.
Node.js supports ECMAScript modules as they are currently specified, and provides limited interoperability between them and the existing CommonJS module format. CommonJS was the original and default module format for Node.js—the require()
syntax expects modules in the form of CommonJS.
The implementation in Node.js is currently experimental; this means it can be subject to breaking API changes. ECMAScript modules are a strategic initiative in Node.js, led by the modules team who are driving the development and implantation of ECMAScript modules in Node.js in line with the ECMAScript international specification.
Getting ready
ECMAScript module support is enabled by default in Node.js versions greater than v13.2.0
although it is still considered experimental...