ES modules

ES modules (ESM) are JavaScript's standard module system, with static import and export. In Node, you enable them with the .mjs extension or "type": "module" in package.json; relative paths must then include the extension, and await is allowed at the top level.

Example

import { readFile } from 'node:fs/promises';
export const lire = (p) => readFile(p, 'utf8');

Related concepts

The whole glossary