Current File : //proc/thread-self/root/kunden/usr/share/doc/nodejs-docs/doc/api/module.json |
{
"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"
}
]
}