NodeJS ESM Module
In recent Node.js LTS (Node 12) releases, it is now possible to use native ESM module within Node.js. That means that Node.js itself can process JavaScript using ESM syntax, although it doesn’t do it by default. The two most common ways to enable ESM syntax are:
- set
"type": "module"within yourpackage.jsonand keep using.jsextension - use the
.mjsfile extensions (recommended)
Reference
Modules: ECMAScript modules | Node.js v21.6.0 Documentation Getting Started with (and Surviving) Node.js ESM Using ECMAScript modules (ESM) with Node.js - LogRocket Blog Move on to ESM-only