diff --git a/.eslintrc.js b/.eslintrc.js index d13fb1709ba..b51b858cc68 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -38,6 +38,7 @@ module.exports = { { files: [ 'doc/api/esm.md', + 'doc/api/modules.md', '*.mjs', 'test/es-module/test-esm-example-loader.js', ], diff --git a/doc/api/modules.md b/doc/api/modules.md index 66e0b9f32dd..9b66eeeeee5 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -918,11 +918,11 @@ added: * Returns: {[`require`][]} Require function ```js -const { createRequire } = require('module'); -const requireUtil = createRequire(require.resolve('../src/utils/')); +import { createRequire } from 'module'; +const require = createRequire(import.meta.url); -// Require `../src/utils/some-tool` -requireUtil('./some-tool'); +// sibling-module.js is a CommonJS module. +const siblingModule = require('./sibling-module'); ``` ### module.createRequireFromPath(filename)