PATH:
usr
/
share
/
doc
/
nodejs-docs-16.20.2
/
doc
/
api
{ "type": "module", "source": "doc/api/module.md", "modules": [ { "textRaw": "Modules: `node:module` API", "name": "modules:_`node:module`_api", "introduced_in": "v12.20.0", "meta": { "added": [ "v0.3.7" ], "changes": [] }, "modules": [ { "textRaw": "The `Module` object", "name": "the_`module`_object", "desc": "<ul>\n<li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\" class=\"type\"><Object></a></li>\n</ul>\n<p>Provides general utility methods when interacting with instances of\n<code>Module</code>, the <a href=\"modules.html#the-module-object\"><code>module</code></a> variable often seen in <a href=\"modules.html\">CommonJS</a> modules. Accessed\nvia <code>import 'node:module'</code> or <code>require('node:module')</code>.</p>", "properties": [ { "textRaw": "`builtinModules` {string\\[]}", "type": "string\\[]", "name": "builtinModules", "meta": { "added": [ "v9.3.0", "v8.10.0", "v6.13.0" ], "changes": [] }, "desc": "<p>A list of the names of all modules provided by Node.js. Can be used to verify\nif a module is maintained by a third party or not.</p>\n<p><code>module</code> in this context isn't the same object that's provided\nby the <a href=\"modules.html#the-module-wrapper\">module wrapper</a>. To access it, require the <code>Module</code> module:</p>\n<pre><code class=\"language-mjs\">// module.mjs\n// In an ECMAScript module\nimport { builtinModules as builtin } from 'node:module';\n</code></pre>\n<pre><code class=\"language-cjs\">// module.cjs\n// In a CommonJS module\nconst builtin = require('node:module').builtinModules;\n</code></pre>" } ], "methods": [ { "textRaw": "`module.createRequire(filename)`", "type": "method", "name": "createRequire", "meta": { "added": [ "v12.2.0" ], "changes": [] }, "signatures": [ { "return": { "textRaw": "Returns: {require} Require function", "name": "return", "type": "require", "desc": "Require function" }, "params": [ { "textRaw": "`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.", "name": "filename", "type": "string|URL", "desc": "Filename to be used to construct the require function. Must be a file URL object, file URL string, or absolute path string." } ] } ], "desc": "<pre><code class=\"language-mjs\">import { createRequire } from 'node:module';\nconst require = createRequire(import.meta.url);\n\n// sibling-module.js is a CommonJS module.\nconst siblingModule = require('./sibling-module');\n</code></pre>" }, { "textRaw": "`module.isBuiltin(moduleName)`", "type": "method", "name": "isBuiltin", "meta": { "added": [ "v16.17.0" ], "changes": [] }, "signatures": [ { "return": { "textRaw": "Returns: {boolean} returns true if the module is builtin else returns false", "name": "return", "type": "boolean", "desc": "returns true if the module is builtin else returns false" }, "params": [ { "textRaw": "`moduleName` {string} name of the module", "name": "moduleName", "type": "string", "desc": "name of the module" } ] } ], "desc": "<pre><code class=\"language-mjs\">import { isBuiltin } from 'node:module';\nisBuiltin('node:fs'); // true\nisBuiltin('fs'); // true\nisBuiltin('wss'); // false\n</code></pre>" }, { "textRaw": "`module.syncBuiltinESMExports()`", "type": "method", "name": "syncBuiltinESMExports", "meta": { "added": [ "v12.12.0" ], "changes": [] }, "signatures": [ { "params": [] } ], "desc": "<p>The <code>module.syncBuiltinESMExports()</code> method updates all the live bindings for\nbuiltin <a href=\"esm.html\">ES Modules</a> to match the properties of the <a href=\"modules.html\">CommonJS</a> exports. It\ndoes not add or remove exported names from the <a href=\"esm.html\">ES Modules</a>.</p>\n<pre><code class=\"language-js\">const fs = require('node:fs');\nconst assert = require('node:assert');\nconst { syncBuiltinESMExports } = require('node:module');\n\nfs.readFile = newAPI;\n\ndelete fs.readFileSync;\n\nfunction newAPI() {\n // ...\n}\n\nfs.newAPI = newAPI;\n\nsyncBuiltinESMExports();\n\nimport('node:fs').then((esmFS) => {\n // It syncs the existing readFile property with the new value\n assert.strictEqual(esmFS.readFile, newAPI);\n // readFileSync has been deleted from the required fs\n assert.strictEqual('readFileSync' in fs, false);\n // syncBuiltinESMExports() does not remove readFileSync from esmFS\n assert.strictEqual('readFileSync' in esmFS, true);\n // syncBuiltinESMExports() does not add names\n assert.strictEqual(esmFS.newAPI, undefined);\n});\n</code></pre>" } ], "type": "module", "displayName": "The `Module` object" }, { "textRaw": "Source map v3 support", "name": "source_map_v3_support", "meta": { "added": [ "v13.7.0", "v12.17.0" ], "changes": [] }, "stability": 1, "stabilityText": "Experimental", "desc": "<p>Helpers for interacting with the source map cache. This cache is\npopulated when source map parsing is enabled and\n<a href=\"https://sourcemaps.info/spec.html#h.lmz475t4mvbx\">source map include directives</a> are found in a modules' footer.</p>\n<p>To enable source map parsing, Node.js must be run with the flag\n<a href=\"cli.html#--enable-source-maps\"><code>--enable-source-maps</code></a>, or with code coverage enabled by setting\n<a href=\"cli.html#node_v8_coveragedir\"><code>NODE_V8_COVERAGE=dir</code></a>.</p>\n<pre><code class=\"language-mjs\">// module.mjs\n// In an ECMAScript module\nimport { findSourceMap, SourceMap } from 'node:module';\n</code></pre>\n<pre><code class=\"language-cjs\">// module.cjs\n// In a CommonJS module\nconst { findSourceMap, SourceMap } = require('node:module');\n</code></pre>\n<!-- Anchors to make sure old links find a target -->\n<p><a id=\"module_module_findsourcemap_path_error\"></a></p>", "methods": [ { "textRaw": "`module.findSourceMap(path)`", "type": "method", "name": "findSourceMap", "meta": { "added": [ "v13.7.0", "v12.17.0" ], "changes": [] }, "signatures": [ { "return": { "textRaw": "Returns: {module.SourceMap}", "name": "return", "type": "module.SourceMap" }, "params": [ { "textRaw": "`path` {string}", "name": "path", "type": "string" } ] } ], "desc": "<p><code>path</code> is the resolved path for the file for which a corresponding source map\nshould be fetched.</p>" } ], "classes": [ { "textRaw": "Class: `module.SourceMap`", "type": "class", "name": "module.SourceMap", "meta": { "added": [ "v13.7.0", "v12.17.0" ], "changes": [] }, "properties": [ { "textRaw": "`payload` Returns: {Object}", "type": "Object", "name": "return", "desc": "<p>Getter for the payload used to construct the <a href=\"#class-modulesourcemap\"><code>SourceMap</code></a> instance.</p>" } ], "methods": [ { "textRaw": "`sourceMap.findEntry(lineNumber, columnNumber)`", "type": "method", "name": "findEntry", "signatures": [ { "return": { "textRaw": "Returns: {Object}", "name": "return", "type": "Object" }, "params": [ { "textRaw": "`lineNumber` {number}", "name": "lineNumber", "type": "number" }, { "textRaw": "`columnNumber` {number}", "name": "columnNumber", "type": "number" } ] } ], "desc": "<p>Given a line number and column number in the generated source file, returns\nan object representing the position in the original file. The object returned\nconsists of the following keys:</p>\n<ul>\n<li>generatedLine: <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\"><number></a></li>\n<li>generatedColumn: <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\"><number></a></li>\n<li>originalSource: <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></li>\n<li>originalLine: <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\"><number></a></li>\n<li>originalColumn: <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\"><number></a></li>\n<li>name: <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></li>\n</ul>" } ], "signatures": [ { "params": [ { "textRaw": "`payload` {Object}", "name": "payload", "type": "Object" } ], "desc": "<p>Creates a new <code>sourceMap</code> instance.</p>\n<p><code>payload</code> is an object with keys matching the <a href=\"https://sourcemaps.info/spec.html#h.mofvlxcwqzej\">Source map v3 format</a>:</p>\n<ul>\n<li><code>file</code>: <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></li>\n<li><code>version</code>: <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\"><number></a></li>\n<li><code>sources</code>: <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string[]></a></li>\n<li><code>sourcesContent</code>: <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string[]></a></li>\n<li><code>names</code>: <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string[]></a></li>\n<li><code>mappings</code>: <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></li>\n<li><code>sourceRoot</code>: <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></li>\n</ul>" } ] } ], "type": "module", "displayName": "Source map v3 support" } ], "type": "module", "displayName": "Modules: `node:module` API" } ] }
[-] async_context.json
[edit]
[-] process.md
[edit]
[-] tracing.html
[edit]
[-] addons.json
[edit]
[-] webstreams.html
[edit]
[-] debugger.md
[edit]
[-] debugger.html
[edit]
[-] tls.json
[edit]
[-] inspector.md
[edit]
[-] child_process.json
[edit]
[-] packages.html
[edit]
[-] events.md
[edit]
[-] synopsis.html
[edit]
[-] inspector.html
[edit]
[-] dgram.json
[edit]
[-] cli.html
[edit]
[-] test.json
[edit]
[-] repl.md
[edit]
[-] worker_threads.md
[edit]
[-] webcrypto.html
[edit]
[-] readline.html
[edit]
[-] crypto.html
[edit]
[-] events.json
[edit]
[-] esm.html
[edit]
[-] querystring.md
[edit]
[-] http.html
[edit]
[-] buffer.md
[edit]
[-] http2.md
[edit]
[-] http.json
[edit]
[-] documentation.json
[edit]
[-] domain.json
[edit]
[-] domain.html
[edit]
[-] embedding.md
[edit]
[-] cluster.md
[edit]
[-] corepack.json
[edit]
[-] errors.md
[edit]
[-] modules.json
[edit]
[-] string_decoder.md
[edit]
[-] v8.md
[edit]
[-] n-api.html
[edit]
[-] module.md
[edit]
[-] querystring.json
[edit]
[+]
..
[-] querystring.html
[edit]
[-] fs.json
[edit]
[-] punycode.md
[edit]
[-] esm.json
[edit]
[-] test.html
[edit]
[-] repl.json
[edit]
[-] async_hooks.html
[edit]
[-] async_hooks.md
[edit]
[-] permissions.md
[edit]
[-] util.md
[edit]
[-] zlib.json
[edit]
[-] synopsis.md
[edit]
[-] vm.md
[edit]
[-] tty.md
[edit]
[-] child_process.html
[edit]
[-] embedding.html
[edit]
[-] stream.html
[edit]
[-] report.json
[edit]
[-] report.md
[edit]
[-] policy.html
[edit]
[-] policy.json
[edit]
[-] index.md
[edit]
[-] addons.html
[edit]
[-] worker_threads.html
[edit]
[-] path.json
[edit]
[-] zlib.md
[edit]
[-] buffer.html
[edit]
[-] perf_hooks.json
[edit]
[-] v8.json
[edit]
[-] modules.html
[edit]
[-] diagnostics_channel.json
[edit]
[-] crypto.json
[edit]
[-] corepack.html
[edit]
[-] index.html
[edit]
[-] os.md
[edit]
[-] async_context.html
[edit]
[-] readline.json
[edit]
[-] async_context.md
[edit]
[-] inspector.json
[edit]
[-] report.html
[edit]
[-] repl.html
[edit]
[-] assert.html
[edit]
[-] test.md
[edit]
[-] packages.json
[edit]
[-] perf_hooks.md
[edit]
[-] deprecations.md
[edit]
[-] intl.json
[edit]
[-] webstreams.json
[edit]
[-] globals.md
[edit]
[-] string_decoder.html
[edit]
[-] cluster.html
[edit]
[-] perf_hooks.html
[edit]
[-] dns.md
[edit]
[-] punycode.html
[edit]
[-] wasi.json
[edit]
[-] n-api.md
[edit]
[-] process.html
[edit]
[-] dgram.md
[edit]
[-] tty.html
[edit]
[-] async_hooks.json
[edit]
[-] tty.json
[edit]
[-] path.md
[edit]
[-] dgram.html
[edit]
[-] console.json
[edit]
[-] intl.html
[edit]
[-] tracing.json
[edit]
[-] vm.json
[edit]
[-] webcrypto.md
[edit]
[-] url.html
[edit]
[-] console.md
[edit]
[-] permissions.json
[edit]
[-] synopsis.json
[edit]
[-] corepack.md
[edit]
[-] embedding.json
[edit]
[-] dns.json
[edit]
[-] https.md
[edit]
[-] documentation.html
[edit]
[-] module.json
[edit]
[-] process.json
[edit]
[-] esm.md
[edit]
[-] util.html
[edit]
[-] tls.md
[edit]
[-] webcrypto.json
[edit]
[-] net.json
[edit]
[-] http2.json
[edit]
[-] cluster.json
[edit]
[-] permissions.html
[edit]
[-] http2.html
[edit]
[-] deprecations.json
[edit]
[-] stream.md
[edit]
[-] https.json
[edit]
[-] url.md
[edit]
[-] vm.html
[edit]
[-] wasi.md
[edit]
[+]
assets
[-] diagnostics_channel.html
[edit]
[-] stream.json
[edit]
[-] all.html
[edit]
[-] punycode.json
[edit]
[-] url.json
[edit]
[-] errors.html
[edit]
[-] cli.md
[edit]
[-] buffer.json
[edit]
[-] worker_threads.json
[edit]
[-] globals.html
[edit]
[-] string_decoder.json
[edit]
[-] console.html
[edit]
[-] v8.html
[edit]
[-] diagnostics_channel.md
[edit]
[-] debugger.json
[edit]
[-] child_process.md
[edit]
[-] deprecations.html
[edit]
[-] os.html
[edit]
[-] wasi.html
[edit]
[-] domain.md
[edit]
[-] os.json
[edit]
[-] readline.md
[edit]
[-] webstreams.md
[edit]
[-] tls.html
[edit]
[-] index.json
[edit]
[-] intl.md
[edit]
[-] tracing.md
[edit]
[-] zlib.html
[edit]
[-] packages.md
[edit]
[-] all.json
[edit]
[-] assert.json
[edit]
[-] fs.html
[edit]
[-] errors.json
[edit]
[-] documentation.md
[edit]
[-] policy.md
[edit]
[-] n-api.json
[edit]
[-] timers.html
[edit]
[-] cli.json
[edit]
[-] modules.md
[edit]
[-] http.md
[edit]
[-] util.json
[edit]
[-] fs.md
[edit]
[-] timers.md
[edit]
[-] globals.json
[edit]
[-] assert.md
[edit]
[-] module.html
[edit]
[-] dns.html
[edit]
[-] net.md
[edit]
[-] events.html
[edit]
[-] timers.json
[edit]
[-] https.html
[edit]
[-] crypto.md
[edit]
[-] path.html
[edit]
[-] addons.md
[edit]
[-] net.html
[edit]