diff --git a/.eslintrc.js b/.eslintrc.js index d13fb1709ba8e9..b51b858cc68859 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/deprecations.md b/doc/api/deprecations.md index 90c2ad5d4f2197..87e537ee4dd194 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -2107,7 +2107,6 @@ Type: Documentation-only [`fs.read()`]: fs.html#fs_fs_read_fd_buffer_offset_length_position_callback [`fs.readSync()`]: fs.html#fs_fs_readsync_fd_buffer_offset_length_position [`fs.stat()`]: fs.html#fs_fs_stat_path_options_callback -[`os.networkInterfaces`]: os.html#os_os_networkinterfaces [`os.tmpdir()`]: os.html#os_os_tmpdir [`process.env`]: process.html#process_process_env [`punycode`]: punycode.html diff --git a/doc/api/modules.md b/doc/api/modules.md index b032f168460c3e..9b66eeeeee58d0 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -905,6 +905,26 @@ by the [module wrapper][]. To access it, require the `Module` module: const builtin = require('module').builtinModules; ``` +### module.createRequire(filename) + + +* `filename` {string|URL} Filename to be used to construct the require + function. Must be a file URL object, file URL string, or absolute path + string. +* Returns: {[`require`][]} Require function + +```js +import { createRequire } from 'module'; +const require = createRequire(import.meta.url); + +// sibling-module.js is a CommonJS module. +const siblingModule = require('./sibling-module'); +``` + ### module.createRequireFromPath(filename)