JavaScript
19 Sep 2026
5 min read
How Node.js Chooses Between .mjs, .cjs, and .js Module Formats
Node.js can execute JavaScript through two module systems: ECMAScript modules (ESM) and CommonJS. The filename is one of the signals that selects between them, which is why files such as postcss.config.mjs appear in projects even when most source files still end in .js. The important detail is that .mjs is not a different JavaScript language. It is an explicit instruction to Node.js: parse and load this file as an ES module.