diff --git a/doc/api/esm.md b/doc/api/esm.md index 086f359f5dee9f..f50aacac41c1c7 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -848,16 +848,15 @@ CommonJS, JSON, and Native modules can be used with [`module.createRequire()`][]. ```js -// cjs.js +// cjs.cjs module.exports = 'cjs'; // esm.mjs import { createRequire } from 'module'; -import { fileURLToPath as fromURL } from 'url'; -const require = createRequire(fromURL(import.meta.url)); +const require = createRequire(import.meta.url); -const cjs = require('./cjs'); +const cjs = require('./cjs.cjs'); cjs === 'cjs'; // true ```