{"$schema":"https://doc-kit.nodejs.org/schemas/api-doc/1.0.0.json","id":"modules","path":"/modules","type":"module","module":"module","title":"Modules: CommonJS modules","introducedIn":"v0.10.0","sourceLink":null,"stability":{"index":"2","description":"Stable"},"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"CommonJS modules are the original way to package JavaScript code for Node.js.\nNode.js also supports the [ECMAScript modules](esm.html) standard used by browsers\nand other JavaScript runtimes.\n\nIn Node.js, each file is treated as a separate module. For\nexample, consider a file named `foo.js`:\n\n```js\nconst circle = require('./circle.js');\nconsole.log(`The area of a circle of radius 4 is ${circle.area(4)}`);\n```\n\nOn the first line, `foo.js` loads the module `circle.js` that is in the same\ndirectory as `foo.js`.\n\nHere are the contents of `circle.js`:\n\n```js\nconst { PI } = Math;\n\nexports.area = (r) => PI * r ** 2;\n\nexports.circumference = (r) => 2 * PI * r;\n```\n\nThe module `circle.js` has exported the functions `area()` and\n`circumference()`. Functions and objects are added to the root of a module\nby specifying additional properties on the special `exports` object.\n\nVariables local to the module will be private, because the module is wrapped\nin a function by Node.js (see [module wrapper](#the-module-wrapper)).\nIn this example, the variable `PI` is private to `circle.js`.\n\nThe `module.exports` property can be assigned a new value (such as a function\nor object).\n\nIn the following code, `bar.js` makes use of the `square` module, which exports\na Square class:\n\n```js\nconst Square = require('./square.js');\nconst mySquare = new Square(2);\nconsole.log(`The area of mySquare is ${mySquare.area()}`);\n```\n\nThe `square` module is defined in `square.js`:\n\n```js\n// Assigning to exports will not modify module, must use module.exports\nmodule.exports = class Square {\n  constructor(width) {\n    this.width = width;\n  }\n\n  area() {\n    return this.width ** 2;\n  }\n};\n```\n\nThe CommonJS module system is implemented in the [`module` core module](module.html).","summary":"CommonJS modules are the original way to package JavaScript code for Node.js. Node.js also supports the ECMAScript modules standard used by browsers and other JavaScript runtimes.","examples":[{"language":"js","displayName":null,"code":"const circle = require('./circle.js');\nconsole.log(`The area of a circle of radius 4 is ${circle.area(4)}`);"},{"language":"js","displayName":null,"code":"const { PI } = Math;\n\nexports.area = (r) => PI * r ** 2;\n\nexports.circumference = (r) => 2 * PI * r;"},{"language":"js","displayName":null,"code":"const Square = require('./square.js');\nconst mySquare = new Square(2);\nconsole.log(`The area of mySquare is ${mySquare.area()}`);"},{"language":"js","displayName":null,"code":"// Assigning to exports will not modify module, must use module.exports\nmodule.exports = class Square {\n  constructor(width) {\n    this.width = width;\n  }\n\n  area() {\n    return this.width ** 2;\n  }\n};"}],"children":[{"kind":"section","id":"enabling","name":"Enabling","title":"Enabling","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"Node.js has two module systems: CommonJS modules and [ECMAScript modules](esm.html).\n\nBy default, Node.js will treat the following as CommonJS modules:\n\n* Files with a `.cjs` extension.\n\n* Files with a `.js` extension or without an extension, when the nearest parent\n  `package.json` file contains a top-level field [`\"type\"`](packages.html#type) with a value of\n  `\"commonjs\"`.\n\n* Files with a `.js` extension or without an extension, when the nearest parent\n  `package.json` file doesn't contain a top-level field [`\"type\"`](packages.html#type) or there is\n  no `package.json` in any parent folder; unless the file contains syntax that\n  errors unless it is evaluated as an ES module. Package authors should include\n  the [`\"type\"`](packages.html#type) field, even in packages where all sources are CommonJS. Being\n  explicit about the `type` of the package will make things easier for build\n  tools and loaders to determine how the files in the package should be\n  interpreted.\n\n* Files with an extension that is not `.mjs`, `.cjs`, `.json`, `.node`, or `.js`,\n  when the nearest parent `package.json` file contains a top-level field\n  [`\"type\"`](packages.html#type) with a value of `\"module\"`.\n\nSee [Determining module system](packages.html#determining-module-system) for more details.\n\nCalling `require()` always use the CommonJS module loader. Calling `import()`\nalways use the ECMAScript module loader.","summary":"Node.js has two module systems: CommonJS modules and ECMAScript modules.","examples":[],"children":[]},{"kind":"section","id":"accessing-the-main-module","name":"Accessing the main module","title":"Accessing the main module","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"When a file is run directly from Node.js, `require.main` is set to its\n`module`. That means that it is possible to determine whether a file has been\nrun directly by testing `require.main === module`.\n\nFor a file `foo.js`, this will be `true` if run via `node foo.js`, but\n`false` if run by `require('./foo')`.\n\nWhen the entry point is not a CommonJS module, `require.main` is `undefined`,\nand the main module is out of reach.","summary":"When a file is run directly from Node.js, `require.main` is set to its `module`. That means that it is possible to determine whether a file has been run directly by testing `require.main === module`.","examples":[],"children":[]},{"kind":"section","id":"package-manager-tips","name":"Package manager tips","title":"Package manager tips","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The semantics of the Node.js `require()` function were designed to be general\nenough to support reasonable directory structures. Package manager programs\nsuch as `dpkg`, `rpm`, and `npm` will hopefully find it possible to build\nnative packages from Node.js modules without modification.\n\nIn the following, we give a suggested directory structure that could work:\n\nLet's say that we wanted to have the folder at\n`/usr/lib/node/<some-package>/<some-version>` hold the contents of a\nspecific version of a package.\n\nPackages can depend on one another. In order to install package `foo`, it\nmay be necessary to install a specific version of package `bar`. The `bar`\npackage may itself have dependencies, and in some cases, these may even collide\nor form cyclic dependencies.\n\nBecause Node.js looks up the `realpath` of any modules it loads (that is, it\nresolves symlinks) and then [looks for their dependencies in `node_modules` folders](#loading-from-node_modules-folders),\nthis situation can be resolved with the following architecture:\n\n* `/usr/lib/node/foo/1.2.3/`: Contents of the `foo` package, version 1.2.3.\n* `/usr/lib/node/bar/4.3.2/`: Contents of the `bar` package that `foo` depends\n  on.\n* `/usr/lib/node/foo/1.2.3/node_modules/bar`: Symbolic link to\n  `/usr/lib/node/bar/4.3.2/`.\n* `/usr/lib/node/bar/4.3.2/node_modules/*`: Symbolic links to the packages that\n  `bar` depends on.\n\nThus, even if a cycle is encountered, or if there are dependency\nconflicts, every module will be able to get a version of its dependency\nthat it can use.\n\nWhen the code in the `foo` package does `require('bar')`, it will get the\nversion that is symlinked into `/usr/lib/node/foo/1.2.3/node_modules/bar`.\nThen, when the code in the `bar` package calls `require('quux')`, it'll get\nthe version that is symlinked into\n`/usr/lib/node/bar/4.3.2/node_modules/quux`.\n\nFurthermore, to make the module lookup process even more optimal, rather\nthan putting packages directly in `/usr/lib/node`, we could put them in\n`/usr/lib/node_modules/<name>/<version>`. Then Node.js will not bother\nlooking for missing dependencies in `/usr/node_modules` or `/node_modules`.\n\nIn order to make modules available to the Node.js REPL, it might be useful to\nalso add the `/usr/lib/node_modules` folder to the `$NODE_PATH` environment\nvariable. Since the module lookups using `node_modules` folders are all\nrelative, and based on the real path of the files making the calls to\n`require()`, the packages themselves can be anywhere.","summary":"The semantics of the Node.js `require()` function were designed to be general enough to support reasonable directory structures. Package manager programs such as `dpkg`, `rpm`, and `npm` will hopefully find it possible to build native packages from Node.js modules without modification.","examples":[],"children":[]},{"kind":"section","id":"loading-ecmascript-modules-using-require","name":"Loading ECMAScript modules using require()","title":"Loading ECMAScript modules using `require()`","scope":"module","overloadOf":null,"stability":null,"added":["v22.0.0","v20.17.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v25.4.0"],"prUrl":"https://github.com/nodejs/node/pull/60959","commit":null,"description":"This feature is no longer experimental."},{"versions":["v23.5.0","v22.13.0","v20.19.0"],"prUrl":"https://github.com/nodejs/node/pull/56194","commit":null,"description":"This feature no longer emits an experimental warning by default, though the warning can still be emitted by --trace-require-module."},{"versions":["v23.0.0","v22.12.0","v20.19.0"],"prUrl":"https://github.com/nodejs/node/pull/55085","commit":null,"description":"This feature is no longer behind the `--experimental-require-module` CLI flag."},{"versions":["v23.0.0","v22.12.0"],"prUrl":"https://github.com/nodejs/node/pull/54563","commit":null,"description":"Support `'module.exports'` interop export in `require(esm)`."}],"description":"The `.mjs` extension is reserved for [ECMAScript Modules](esm.html).\nSee [Determining module system](packages.html#determining-module-system) section for more info\nregarding which files are parsed as ECMAScript modules.\n\n`require()` only supports loading ECMAScript modules that meet the following requirements:\n\n* The module is fully synchronous (contains no top-level `await`); and\n* One of these conditions are met:\n  1. The file has a `.mjs` extension.\n  2. The file has a `.js` extension, and the closest `package.json` contains `\"type\": \"module\"`\n  3. The file has a `.js` extension, the closest `package.json` does not contain\n     `\"type\": \"commonjs\"`, and the module contains ES module syntax.\n\nIf the ES Module being loaded meets the requirements, `require()` can load it and\nreturn the [module namespace object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import#module_namespace_object). In this case it is similar to dynamic\n`import()` but is run synchronously and returns the name space object\ndirectly.\n\nWith the following ES Modules:\n\n```mjs\n// distance.mjs\nexport function distance(a, b) { return Math.sqrt((b.x - a.x) ** 2 + (b.y - a.y) ** 2); }\n```\n\n```mjs\n// point.mjs\nexport default class Point {\n  constructor(x, y) { this.x = x; this.y = y; }\n}\n```\n\nA CommonJS module can load them with `require()`:\n\n```cjs\nconst distance = require('./distance.mjs');\nconsole.log(distance);\n// [Module: null prototype] {\n//   distance: [Function: distance]\n// }\n\nconst point = require('./point.mjs');\nconsole.log(point);\n// [Module: null prototype] {\n//   default: [class Point],\n//   __esModule: true,\n// }\n```\n\nFor interoperability with existing tools that convert ES Modules into CommonJS,\nwhich could then load real ES Modules through `require()`, the returned namespace\nwould contain a `__esModule: true` property if it has a `default` export so that\nconsuming code generated by tools can recognize the default exports in real\nES Modules. If the namespace already defines `__esModule`, this would not be added.\nThis property is experimental and can change in the future. It should only be used\nby tools converting ES modules into CommonJS modules, following existing ecosystem\nconventions. Code authored directly in CommonJS should avoid depending on it.\n\nThe result returned by `require()` is the [module namespace object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import#module_namespace_object), which places\nthe default export in the `.default` property, similar to the results returned by `import()`.\nTo customize what should be returned by `require(esm)` directly, the ES Module can export the\ndesired value using the string name `\"module.exports\"`.\n\n```mjs\n// point.mjs\nexport default class Point {\n  constructor(x, y) { this.x = x; this.y = y; }\n}\n\n// `distance` is lost to CommonJS consumers of this module, unless it's\n// added to `Point` as a static property.\nexport function distance(a, b) { return Math.sqrt((b.x - a.x) ** 2 + (b.y - a.y) ** 2); }\nexport { Point as 'module.exports' };\n```\n\n```cjs\nconst Point = require('./point.mjs');\nconsole.log(Point); // [class Point]\n\n// Named exports are lost when 'module.exports' is used\nconst { distance } = require('./point.mjs');\nconsole.log(distance); // undefined\n```\n\nNotice in the example above, when the `module.exports` export name is used, named exports\nwill be lost to CommonJS consumers. To allow CommonJS consumers to continue accessing\nnamed exports, the module can make sure that the default export is an object with the\nnamed exports attached to it as properties. For example with the example above,\n`distance` can be attached to the default export, the `Point` class, as a static method.\n\n```mjs\nexport function distance(a, b) { return Math.sqrt((b.x - a.x) ** 2 + (b.y - a.y) ** 2); }\n\nexport default class Point {\n  constructor(x, y) { this.x = x; this.y = y; }\n  static distance = distance;\n}\n\nexport { Point as 'module.exports' };\n```\n\n```cjs\nconst Point = require('./point.mjs');\nconsole.log(Point); // [class Point]\n\nconst { distance } = require('./point.mjs');\nconsole.log(distance); // [Function: distance]\n```\n\nIf the module being `require()`'d contains top-level `await`, or the module\ngraph it `import`s contains top-level `await`,\n[`ERR_REQUIRE_ASYNC_MODULE`](errors.html#err_require_async_module) will be thrown. In this case, users should\nload the asynchronous module using [`import()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import).\n\nIf `--experimental-print-required-tla` is enabled and the error is uncaught,\nNode.js will try to locate the top-level `await`s in the `require()`'d module graph\nand print the locations in the stderr.\n\nIf support for loading ES modules using `require()` results in unexpected\nbreakage, it can be disabled using `--no-require-module`.\nTo print where this feature is used, use [`--trace-require-module`](cli.html#--trace-require-modulemode).\n\nThis feature can be detected by checking if\n[`process.features.require_module`](process.html#processfeaturesrequire_module) is `true`.","summary":"The `.mjs` extension is reserved for ECMAScript Modules. See Determining module system section for more info regarding which files are parsed as ECMAScript modules.","examples":[{"language":"mjs","displayName":null,"code":"// distance.mjs\nexport function distance(a, b) { return Math.sqrt((b.x - a.x) ** 2 + (b.y - a.y) ** 2); }"},{"language":"mjs","displayName":null,"code":"// point.mjs\nexport default class Point {\n  constructor(x, y) { this.x = x; this.y = y; }\n}"},{"language":"cjs","displayName":null,"code":"const distance = require('./distance.mjs');\nconsole.log(distance);\n// [Module: null prototype] {\n//   distance: [Function: distance]\n// }\n\nconst point = require('./point.mjs');\nconsole.log(point);\n// [Module: null prototype] {\n//   default: [class Point],\n//   __esModule: true,\n// }"},{"language":"mjs","displayName":null,"code":"// point.mjs\nexport default class Point {\n  constructor(x, y) { this.x = x; this.y = y; }\n}\n\n// `distance` is lost to CommonJS consumers of this module, unless it's\n// added to `Point` as a static property.\nexport function distance(a, b) { return Math.sqrt((b.x - a.x) ** 2 + (b.y - a.y) ** 2); }\nexport { Point as 'module.exports' };"},{"language":"cjs","displayName":null,"code":"const Point = require('./point.mjs');\nconsole.log(Point); // [class Point]\n\n// Named exports are lost when 'module.exports' is used\nconst { distance } = require('./point.mjs');\nconsole.log(distance); // undefined"},{"language":"mjs","displayName":null,"code":"export function distance(a, b) { return Math.sqrt((b.x - a.x) ** 2 + (b.y - a.y) ** 2); }\n\nexport default class Point {\n  constructor(x, y) { this.x = x; this.y = y; }\n  static distance = distance;\n}\n\nexport { Point as 'module.exports' };"},{"language":"cjs","displayName":null,"code":"const Point = require('./point.mjs');\nconsole.log(Point); // [class Point]\n\nconst { distance } = require('./point.mjs');\nconsole.log(distance); // [Function: distance]"}],"children":[]},{"kind":"section","id":"all-together","name":"All together","title":"All together","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"To get the exact filename that will be loaded when `require()` is called, use\nthe `require.resolve()` function.\n\nPutting together all of the above, here is the high-level algorithm\nin pseudocode of what `require()` does:\n\n```text\nrequire(X) from module at path Y\n1. If X is a core module,\n   a. return the core module\n   b. STOP\n2. If X begins with '/'\n   a. set Y to the file system root\n3. If X is equal to '.', or X begins with './', '/' or '../'\n   a. LOAD_AS_FILE(Y + X)\n   b. LOAD_AS_DIRECTORY(Y + X)\n   c. THROW \"not found\"\n4. If X begins with '#'\n   a. LOAD_PACKAGE_IMPORTS(X, dirname(Y))\n5. LOAD_PACKAGE_SELF(X, dirname(Y))\n6. If a package map PACKAGE_MAP exists,\n   a. Find the package ID for the package owning Y\n        1. Let PARENT_PACKAGE_ID be FIND_PACKAGE_ID(dirname(Y), PACKAGE_MAP)\n   b. LOAD_PACKAGE_MAP(X, PARENT_PACKAGE_ID, PACKAGE_MAP)\n7. LOAD_NODE_MODULES(X, dirname(Y))\n8. THROW \"not found\"\n\nMAYBE_DETECT_AND_LOAD(X)\n1. If X parses as a CommonJS module, load X as a CommonJS module. STOP.\n2. Else, if the source code of X can be parsed as ECMAScript module using\n  DETECT_MODULE_SYNTAX defined in the ESM resolver,\n  a. Load X as an ECMAScript module. STOP.\n3. THROW the SyntaxError from attempting to parse X as CommonJS in 1. STOP.\n\nLOAD_AS_FILE(X)\n1. If X is a file, load X as its file extension format. STOP\n2. If X.js is a file,\n    a. Find the closest package scope SCOPE to X.\n    b. If no scope was found\n      1. MAYBE_DETECT_AND_LOAD(X.js)\n    c. If the SCOPE/package.json contains \"type\" field,\n      1. If the \"type\" field is \"module\", load X.js as an ECMAScript module. STOP.\n      2. If the \"type\" field is \"commonjs\", load X.js as a CommonJS module. STOP.\n    d. MAYBE_DETECT_AND_LOAD(X.js)\n3. If X.json is a file, load X.json to a JavaScript Object. STOP\n4. If X.node is a file, load X.node as binary addon. STOP\n\nLOAD_INDEX(X)\n1. If X/index.js is a file\n    a. Find the closest package scope SCOPE to X.\n    b. If no scope was found, load X/index.js as a CommonJS module. STOP.\n    c. If the SCOPE/package.json contains \"type\" field,\n      1. If the \"type\" field is \"module\", load X/index.js as an ECMAScript module. STOP.\n      2. Else, load X/index.js as a CommonJS module. STOP.\n2. If X/index.json is a file, parse X/index.json to a JavaScript object. STOP\n3. If X/index.node is a file, load X/index.node as binary addon. STOP\n\nLOAD_AS_DIRECTORY(X)\n1. If X/package.json is a file,\n   a. Parse X/package.json, and look for \"main\" field.\n   b. If \"main\" is a falsy value, GOTO 2.\n   c. let M = X + (json main field)\n   d. LOAD_AS_FILE(M)\n   e. LOAD_INDEX(M)\n   f. LOAD_INDEX(X) DEPRECATED\n   g. THROW \"not found\"\n2. LOAD_INDEX(X)\n\nLOAD_NODE_MODULES(X, START)\n1. Try to interpret X as a combination of NAME and SUBPATH where the name\n   may have a @scope/ prefix and the subpath begins with a slash (`/`).\n2. let DIRS = NODE_MODULES_PATHS(START)\n3. for each DIR in DIRS:\n   a. LOAD_PACKAGE_EXPORTS(SUBPATH, DIR/NAME)\n   b. LOAD_AS_FILE(DIR/X)\n   c. LOAD_AS_DIRECTORY(DIR/X)\n\nNODE_MODULES_PATHS(START)\n1. let PARTS = path split(START)\n2. let I = count of PARTS - 1\n3. let DIRS = []\n4. while I >= 0,\n   a. if PARTS[I] = \"node_modules\", GOTO d.\n   b. DIR = path join(PARTS[0 .. I] + \"node_modules\")\n   c. DIRS = DIRS + DIR\n   d. let I = I - 1\n5. return DIRS + GLOBAL_FOLDERS\n\nFIND_PACKAGE_ID(PATH, PACKAGE_MAP)\n1. Find the PACKAGE_ID for the entry whose \"path\" is a parent directory of PATH\n2. If multiple entries are found, THROW \"ambiguous resolution\"\n3. If no entry was found, THROW \"external file\".\n4. return PACKAGE_ID\n\nLOAD_PACKAGE_MAP(X, PARENT_PACKAGE_ID, PACKAGE_MAP)\n1. Try to interpret X as a combination of NAME and SUBPATH where the name\n   may have a @scope/ prefix and the subpath begins with a slash (`/`).\n2. Find the package map entry for key PARENT_PACKAGE_ID\n3. Look up NAME in the entry's \"dependencies\" map.\n4. If NAME is not found, THROW \"not found\".\n5. Let TARGET be PACKAGE_MAP.packages[dependencies[name]]\n6. Let PACKAGE_PATH be the resolved path of TARGET.\n7. LOAD_PACKAGE_EXPORTS(SUBPATH, PACKAGE_PATH)\n8. LOAD_AS_FILE(PACKAGE_PATH/SUBPATH)\n9. LOAD_AS_DIRECTORY(PACKAGE_PATH/SUBPATH)\n10. THROW \"not found\"\n\nLOAD_PACKAGE_IMPORTS(X, DIR)\n1. Find the closest package scope SCOPE to DIR.\n2. If no scope was found, return.\n3. If the SCOPE/package.json \"imports\" is null or undefined, return.\n4. If `--no-require-module` is not enabled\n  a. let CONDITIONS = [\"node\", \"require\", \"module-sync\"]\n  b. Else, let CONDITIONS = [\"node\", \"require\"]\n5. let MATCH = PACKAGE_IMPORTS_RESOLVE(X, pathToFileURL(SCOPE),\n  CONDITIONS) defined in the ESM resolver.\n6. RESOLVE_ESM_MATCH(MATCH).\n\nLOAD_PACKAGE_EXPORTS(SUBPATH, PACKAGE_DIR)\n1. Parse PACKAGE_DIR/package.json, and look for \"exports\" field.\n2. If \"exports\" is null or undefined, return.\n3. If `--no-require-module` is not enabled\n  a. let CONDITIONS = [\"node\", \"require\", \"module-sync\"]\n  b. Else, let CONDITIONS = [\"node\", \"require\"]\n4. let MATCH = PACKAGE_EXPORTS_RESOLVE(pathToFileURL(PACKAGE_DIR), \".\" + SUBPATH,\n   `package.json` \"exports\", CONDITIONS) defined in the ESM resolver.\n5. RESOLVE_ESM_MATCH(MATCH)\n\nLOAD_PACKAGE_SELF(X, DIR)\n1. Find the closest package scope SCOPE to DIR.\n2. If no scope was found, return.\n3. If the SCOPE/package.json \"exports\" is null or undefined, return.\n4. If the SCOPE/package.json \"name\" is not the first segment of X, return.\n5. let MATCH = PACKAGE_EXPORTS_RESOLVE(pathToFileURL(SCOPE),\n   \".\" + X.slice(\"name\".length), `package.json` \"exports\", [\"node\", \"require\"])\n   defined in the ESM resolver.\n6. RESOLVE_ESM_MATCH(MATCH)\n\nRESOLVE_ESM_MATCH(MATCH)\n1. let RESOLVED_PATH = fileURLToPath(MATCH)\n2. If the file at RESOLVED_PATH exists, load RESOLVED_PATH as its extension\n   format. STOP\n3. THROW \"not found\"\n```\n\nThe \"ESM resolver\" is defined [in the ESM documentation](esm.html#resolution-and-loading-algorithm).","summary":"To get the exact filename that will be loaded when `require()` is called, use the `require.resolve()` function.","examples":[{"language":"text","displayName":null,"code":"require(X) from module at path Y\n1. If X is a core module,\n   a. return the core module\n   b. STOP\n2. If X begins with '/'\n   a. set Y to the file system root\n3. If X is equal to '.', or X begins with './', '/' or '../'\n   a. LOAD_AS_FILE(Y + X)\n   b. LOAD_AS_DIRECTORY(Y + X)\n   c. THROW \"not found\"\n4. If X begins with '#'\n   a. LOAD_PACKAGE_IMPORTS(X, dirname(Y))\n5. LOAD_PACKAGE_SELF(X, dirname(Y))\n6. If a package map PACKAGE_MAP exists,\n   a. Find the package ID for the package owning Y\n        1. Let PARENT_PACKAGE_ID be FIND_PACKAGE_ID(dirname(Y), PACKAGE_MAP)\n   b. LOAD_PACKAGE_MAP(X, PARENT_PACKAGE_ID, PACKAGE_MAP)\n7. LOAD_NODE_MODULES(X, dirname(Y))\n8. THROW \"not found\"\n\nMAYBE_DETECT_AND_LOAD(X)\n1. If X parses as a CommonJS module, load X as a CommonJS module. STOP.\n2. Else, if the source code of X can be parsed as ECMAScript module using\n  DETECT_MODULE_SYNTAX defined in the ESM resolver,\n  a. Load X as an ECMAScript module. STOP.\n3. THROW the SyntaxError from attempting to parse X as CommonJS in 1. STOP.\n\nLOAD_AS_FILE(X)\n1. If X is a file, load X as its file extension format. STOP\n2. If X.js is a file,\n    a. Find the closest package scope SCOPE to X.\n    b. If no scope was found\n      1. MAYBE_DETECT_AND_LOAD(X.js)\n    c. If the SCOPE/package.json contains \"type\" field,\n      1. If the \"type\" field is \"module\", load X.js as an ECMAScript module. STOP.\n      2. If the \"type\" field is \"commonjs\", load X.js as a CommonJS module. STOP.\n    d. MAYBE_DETECT_AND_LOAD(X.js)\n3. If X.json is a file, load X.json to a JavaScript Object. STOP\n4. If X.node is a file, load X.node as binary addon. STOP\n\nLOAD_INDEX(X)\n1. If X/index.js is a file\n    a. Find the closest package scope SCOPE to X.\n    b. If no scope was found, load X/index.js as a CommonJS module. STOP.\n    c. If the SCOPE/package.json contains \"type\" field,\n      1. If the \"type\" field is \"module\", load X/index.js as an ECMAScript module. STOP.\n      2. Else, load X/index.js as a CommonJS module. STOP.\n2. If X/index.json is a file, parse X/index.json to a JavaScript object. STOP\n3. If X/index.node is a file, load X/index.node as binary addon. STOP\n\nLOAD_AS_DIRECTORY(X)\n1. If X/package.json is a file,\n   a. Parse X/package.json, and look for \"main\" field.\n   b. If \"main\" is a falsy value, GOTO 2.\n   c. let M = X + (json main field)\n   d. LOAD_AS_FILE(M)\n   e. LOAD_INDEX(M)\n   f. LOAD_INDEX(X) DEPRECATED\n   g. THROW \"not found\"\n2. LOAD_INDEX(X)\n\nLOAD_NODE_MODULES(X, START)\n1. Try to interpret X as a combination of NAME and SUBPATH where the name\n   may have a @scope/ prefix and the subpath begins with a slash (`/`).\n2. let DIRS = NODE_MODULES_PATHS(START)\n3. for each DIR in DIRS:\n   a. LOAD_PACKAGE_EXPORTS(SUBPATH, DIR/NAME)\n   b. LOAD_AS_FILE(DIR/X)\n   c. LOAD_AS_DIRECTORY(DIR/X)\n\nNODE_MODULES_PATHS(START)\n1. let PARTS = path split(START)\n2. let I = count of PARTS - 1\n3. let DIRS = []\n4. while I >= 0,\n   a. if PARTS[I] = \"node_modules\", GOTO d.\n   b. DIR = path join(PARTS[0 .. I] + \"node_modules\")\n   c. DIRS = DIRS + DIR\n   d. let I = I - 1\n5. return DIRS + GLOBAL_FOLDERS\n\nFIND_PACKAGE_ID(PATH, PACKAGE_MAP)\n1. Find the PACKAGE_ID for the entry whose \"path\" is a parent directory of PATH\n2. If multiple entries are found, THROW \"ambiguous resolution\"\n3. If no entry was found, THROW \"external file\".\n4. return PACKAGE_ID\n\nLOAD_PACKAGE_MAP(X, PARENT_PACKAGE_ID, PACKAGE_MAP)\n1. Try to interpret X as a combination of NAME and SUBPATH where the name\n   may have a @scope/ prefix and the subpath begins with a slash (`/`).\n2. Find the package map entry for key PARENT_PACKAGE_ID\n3. Look up NAME in the entry's \"dependencies\" map.\n4. If NAME is not found, THROW \"not found\".\n5. Let TARGET be PACKAGE_MAP.packages[dependencies[name]]\n6. Let PACKAGE_PATH be the resolved path of TARGET.\n7. LOAD_PACKAGE_EXPORTS(SUBPATH, PACKAGE_PATH)\n8. LOAD_AS_FILE(PACKAGE_PATH/SUBPATH)\n9. LOAD_AS_DIRECTORY(PACKAGE_PATH/SUBPATH)\n10. THROW \"not found\"\n\nLOAD_PACKAGE_IMPORTS(X, DIR)\n1. Find the closest package scope SCOPE to DIR.\n2. If no scope was found, return.\n3. If the SCOPE/package.json \"imports\" is null or undefined, return.\n4. If `--no-require-module` is not enabled\n  a. let CONDITIONS = [\"node\", \"require\", \"module-sync\"]\n  b. Else, let CONDITIONS = [\"node\", \"require\"]\n5. let MATCH = PACKAGE_IMPORTS_RESOLVE(X, pathToFileURL(SCOPE),\n  CONDITIONS) defined in the ESM resolver.\n6. RESOLVE_ESM_MATCH(MATCH).\n\nLOAD_PACKAGE_EXPORTS(SUBPATH, PACKAGE_DIR)\n1. Parse PACKAGE_DIR/package.json, and look for \"exports\" field.\n2. If \"exports\" is null or undefined, return.\n3. If `--no-require-module` is not enabled\n  a. let CONDITIONS = [\"node\", \"require\", \"module-sync\"]\n  b. Else, let CONDITIONS = [\"node\", \"require\"]\n4. let MATCH = PACKAGE_EXPORTS_RESOLVE(pathToFileURL(PACKAGE_DIR), \".\" + SUBPATH,\n   `package.json` \"exports\", CONDITIONS) defined in the ESM resolver.\n5. RESOLVE_ESM_MATCH(MATCH)\n\nLOAD_PACKAGE_SELF(X, DIR)\n1. Find the closest package scope SCOPE to DIR.\n2. If no scope was found, return.\n3. If the SCOPE/package.json \"exports\" is null or undefined, return.\n4. If the SCOPE/package.json \"name\" is not the first segment of X, return.\n5. let MATCH = PACKAGE_EXPORTS_RESOLVE(pathToFileURL(SCOPE),\n   \".\" + X.slice(\"name\".length), `package.json` \"exports\", [\"node\", \"require\"])\n   defined in the ESM resolver.\n6. RESOLVE_ESM_MATCH(MATCH)\n\nRESOLVE_ESM_MATCH(MATCH)\n1. let RESOLVED_PATH = fileURLToPath(MATCH)\n2. If the file at RESOLVED_PATH exists, load RESOLVED_PATH as its extension\n   format. STOP\n3. THROW \"not found\""}],"children":[]},{"kind":"section","id":"caching","name":"Caching","title":"Caching","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"Modules are cached after the first time they are loaded. This means (among other\nthings) that every call to `require('foo')` will get exactly the same object\nreturned, if it would resolve to the same file.\n\nProvided `require.cache` is not modified, multiple calls to `require('foo')`\nwill not cause the module code to be executed multiple times. This is an\nimportant feature. With it, \"partially done\" objects can be returned, thus\nallowing transitive dependencies to be loaded even when they would cause cycles.\n\nTo have a module execute code multiple times, export a function, and call that\nfunction.","summary":"Modules are cached after the first time they are loaded. This means (among other things) that every call to `require('foo')` will get exactly the same object returned, if it would resolve to the same file.","examples":[],"children":[{"kind":"section","id":"module-caching-caveats","name":"Module caching caveats","title":"Module caching caveats","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"Modules are cached based on their resolved filename. Since modules may resolve\nto a different filename based on the location of the calling module (loading\nfrom `node_modules` folders), it is not a *guarantee* that `require('foo')` will\nalways return the exact same object, if it would resolve to different files.\n\nAdditionally, on case-insensitive file systems or operating systems, different\nresolved filenames can point to the same file, but the cache will still treat\nthem as different modules and will reload the file multiple times. For example,\n`require('./foo')` and `require('./FOO')` return two different objects,\nirrespective of whether or not `./foo` and `./FOO` are the same file.","summary":"Modules are cached based on their resolved filename. Since modules may resolve to a different filename based on the location of the calling module (loading from `node_modules` folders), it is not a _guarantee_ that `require('foo')` will always return the exact same object, if it would resolve to different files.","examples":[],"children":[]}]},{"kind":"section","id":"built-in-modules","name":"Built-in modules","title":"Built-in modules","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v16.0.0","v14.18.0"],"prUrl":"https://github.com/nodejs/node/pull/37246","commit":null,"description":"Added `node:` import support to `require(...)`."}],"description":"Node.js has several modules compiled into the binary. These modules are\ndescribed in greater detail elsewhere in this documentation.\n\nThe built-in modules are defined within the Node.js source and are located in the\n`lib/` folder.\n\nBuilt-in modules can be identified using the `node:` prefix, in which case\nit bypasses the `require` cache. For instance, `require('node:http')` will\nalways return the built in HTTP module, even if there is `require.cache` entry\nby that name.\n\nSome built-in modules are always preferentially loaded if their identifier is\npassed to `require()`. For instance, `require('http')` will always\nreturn the built-in HTTP module, even if there is a file by that name.\n\nThe list of all the built-in modules can be retrieved from [`module.builtinModules`](module.html#modulebuiltinmodules).\nThe modules being all listed without the `node:` prefix, except those that mandate such\nprefix (as explained in the next section).","summary":"Node.js has several modules compiled into the binary. These modules are described in greater detail elsewhere in this documentation.","examples":[],"children":[{"kind":"section","id":"built-in-modules-with-mandatory-node-prefix","name":"Built-in modules with mandatory node: prefix","title":"Built-in modules with mandatory `node:` prefix","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"When being loaded by `require()`, some built-in modules must be requested with the\n`node:` prefix. This requirement exists to prevent newly introduced built-in\nmodules from having a conflict with user land packages that already have\ntaken the name. Currently the built-in modules that requires the `node:` prefix are:\n\n* [`node:ffi`](ffi.html)\n* [`node:sea`](single-executable-applications.html#single-executable-application-api)\n* [`node:sqlite`](sqlite.html)\n* [`node:test`](test.html)\n* [`node:test/reporters`](test.html#test-reporters)\n\nThe list of these modules is exposed in [`module.builtinModules`](module.html#modulebuiltinmodules), including the prefix.","summary":"When being loaded by `require()`, some built-in modules must be requested with the `node:` prefix. This requirement exists to prevent newly introduced built-in modules from having a conflict with user land packages that already have taken the name. Currently the built-in modules that requires the `node:` prefix are:","examples":[],"children":[]}]},{"kind":"section","id":"cycles","name":"Cycles","title":"Cycles","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"When there are circular `require()` calls, a module might not have finished\nexecuting when it is returned.\n\nConsider this situation:\n\n`a.js`:\n\n```js\nconsole.log('a starting');\nexports.done = false;\nconst b = require('./b.js');\nconsole.log('in a, b.done = %j', b.done);\nexports.done = true;\nconsole.log('a done');\n```\n\n`b.js`:\n\n```js\nconsole.log('b starting');\nexports.done = false;\nconst a = require('./a.js');\nconsole.log('in b, a.done = %j', a.done);\nexports.done = true;\nconsole.log('b done');\n```\n\n`main.js`:\n\n```js\nconsole.log('main starting');\nconst a = require('./a.js');\nconst b = require('./b.js');\nconsole.log('in main, a.done = %j, b.done = %j', a.done, b.done);\n```\n\nWhen `main.js` loads `a.js`, then `a.js` in turn loads `b.js`. At that\npoint, `b.js` tries to load `a.js`. In order to prevent an infinite\nloop, an **unfinished copy** of the `a.js` exports object is returned to the\n`b.js` module. `b.js` then finishes loading, and its `exports` object is\nprovided to the `a.js` module.\n\nBy the time `main.js` has loaded both modules, they're both finished.\nThe output of this program would thus be:\n\n```console\n$ node main.js\nmain starting\na starting\nb starting\nin b, a.done = false\nb done\nin a, b.done = true\na done\nin main, a.done = true, b.done = true\n```\n\nCareful planning is required to allow cyclic module dependencies to work\ncorrectly within an application.","summary":"When there are circular `require()` calls, a module might not have finished executing when it is returned.","examples":[{"language":"js","displayName":null,"code":"console.log('a starting');\nexports.done = false;\nconst b = require('./b.js');\nconsole.log('in a, b.done = %j', b.done);\nexports.done = true;\nconsole.log('a done');"},{"language":"js","displayName":null,"code":"console.log('b starting');\nexports.done = false;\nconst a = require('./a.js');\nconsole.log('in b, a.done = %j', a.done);\nexports.done = true;\nconsole.log('b done');"},{"language":"js","displayName":null,"code":"console.log('main starting');\nconst a = require('./a.js');\nconst b = require('./b.js');\nconsole.log('in main, a.done = %j, b.done = %j', a.done, b.done);"},{"language":"console","displayName":null,"code":"$ node main.js\nmain starting\na starting\nb starting\nin b, a.done = false\nb done\nin a, b.done = true\na done\nin main, a.done = true, b.done = true"}],"children":[]},{"kind":"section","id":"file-modules","name":"File modules","title":"File modules","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"If the exact filename is not found, then Node.js will attempt to load the\nrequired filename with the added extensions: `.js`, `.json`, and finally\n`.node`. When loading a file that has a different extension (e.g. `.cjs`), its\nfull name must be passed to `require()`, including its file extension (e.g.\n`require('./file.cjs')`).\n\n`.json` files are parsed as JSON text files, `.node` files are interpreted as\ncompiled addon modules loaded with `process.dlopen()`. Files using any other\nextension (or no extension at all) are parsed as JavaScript text files. Refer to\nthe [Determining module system](packages.html#determining-module-system) section to understand what parse goal will be\nused.\n\nA required module prefixed with `'/'` is an absolute path to the file. For\nexample, `require('/home/marco/foo.js')` will load the file at\n`/home/marco/foo.js`.\n\nA required module prefixed with `'./'` is relative to the file calling\n`require()`. That is, `circle.js` must be in the same directory as `foo.js` for\n`require('./circle')` to find it.\n\nWithout a leading `'/'`, `'./'`, or `'../'` to indicate a file, the module must\neither be a core module or is loaded from a `node_modules` folder.\n\nIf the given path does not exist, `require()` will throw a\n[`MODULE_NOT_FOUND`](errors.html#module_not_found) error.","summary":"If the exact filename is not found, then Node.js will attempt to load the required filename with the added extensions: `.js`, `.json`, and finally `.node`. When loading a file that has a different extension (e.g. `.cjs`), its full name must be passed to `require()`, including its file extension (e.g. `require('./file.cjs')`).","examples":[],"children":[]},{"kind":"section","id":"folders-as-modules","name":"Folders as modules","title":"Folders as modules","scope":"module","overloadOf":null,"stability":{"index":"3","description":"Legacy: Use [subpath exports](packages.html#subpath-exports) or [subpath imports](packages.html#subpath-imports) instead."},"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"There are three ways in which a folder may be passed to `require()` as\nan argument.\n\nThe first is to create a [`package.json`](packages.html#nodejs-packagejson-field-definitions) file in the root of the folder,\nwhich specifies a `main` module. An example [`package.json`](packages.html#nodejs-packagejson-field-definitions) file might\nlook like this:\n\n```json\n{ \"name\" : \"some-library\",\n  \"main\" : \"./lib/some-library.js\" }\n```\n\nIf this was in a folder at `./some-library`, then\n`require('./some-library')` would attempt to load\n`./some-library/lib/some-library.js`.\n\nIf there is no [`package.json`](packages.html#nodejs-packagejson-field-definitions) file present in the directory, or if the\n[`\"main\"`](packages.html#main) entry is missing or cannot be resolved, then Node.js\nwill attempt to load an `index.js` or `index.node` file out of that\ndirectory. For example, if there was no [`package.json`](packages.html#nodejs-packagejson-field-definitions) file in the previous\nexample, then `require('./some-library')` would attempt to load:\n\n* `./some-library/index.js`\n* `./some-library/index.node`\n\nIf these attempts fail, then Node.js will report the entire module as missing\nwith the default error:\n\n```console\nError: Cannot find module 'some-library'\n```\n\nIn all three above cases, an `import('./some-library')` call would result in a\n[`ERR_UNSUPPORTED_DIR_IMPORT`](errors.html#err_unsupported_dir_import) error. Using package [subpath exports](packages.html#subpath-exports) or\n[subpath imports](packages.html#subpath-imports) can provide the same containment organization benefits as\nfolders as modules, and work for both `require` and `import`.","summary":"There are three ways in which a folder may be passed to `require()` as an argument.","examples":[{"language":"json","displayName":null,"code":"{ \"name\" : \"some-library\",\n  \"main\" : \"./lib/some-library.js\" }"},{"language":"console","displayName":null,"code":"Error: Cannot find module 'some-library'"}],"children":[]},{"kind":"section","id":"loading-from-node_modules-folders","name":"Loading from node_modules folders","title":"Loading from `node_modules` folders","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"If the module identifier passed to `require()` is not a\n[built-in](#built-in-modules) module, and does not begin with `'/'`, `'../'`, or\n`'./'`, then Node.js starts at the directory of the current module, and\nadds `/node_modules`, and attempts to load the module from that location.\nNode.js will not append `node_modules` to a path already ending in\n`node_modules`.\n\nIf it is not found there, then it moves to the parent directory, and so\non, until the root of the file system is reached.\n\nFor example, if the file at `'/home/ry/projects/foo.js'` called\n`require('bar.js')`, then Node.js would look in the following locations, in\nthis order:\n\n* `/home/ry/projects/node_modules/bar.js`\n* `/home/ry/node_modules/bar.js`\n* `/home/node_modules/bar.js`\n* `/node_modules/bar.js`\n\nThis allows programs to localize their dependencies, so that they do not\nclash.\n\nIt is possible to require specific files or sub modules distributed with a\nmodule by including a path suffix after the module name. For instance\n`require('example-module/path/to/file')` would resolve `path/to/file`\nrelative to where `example-module` is located. The suffixed path follows the\nsame module resolution semantics.","summary":"If the module identifier passed to `require()` is not a built-in module, and does not begin with `'/'`, `'../'`, or `'./'`, then Node.js starts at the directory of the current module, and adds `/node_modules`, and attempts to load the module from that location. Node.js will not append `node_modules` to a path already ending in `node_modules`.","examples":[],"children":[]},{"kind":"section","id":"loading-from-the-global-folders","name":"Loading from the global folders","title":"Loading from the global folders","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"If the `NODE_PATH` environment variable is set to a colon-delimited list\nof absolute paths, then Node.js will search those paths for modules if they\nare not found elsewhere.\n\nOn Windows, `NODE_PATH` is delimited by semicolons (`;`) instead of colons.\n\n`NODE_PATH` was originally created to support loading modules from\nvarying paths before the current [module resolution](#all-together) algorithm was defined.\n\n`NODE_PATH` is still supported, but is less necessary now that the Node.js\necosystem has settled on a convention for locating dependent modules.\nSometimes deployments that rely on `NODE_PATH` show surprising behavior\nwhen people are unaware that `NODE_PATH` must be set. Sometimes a\nmodule's dependencies change, causing a different version (or even a\ndifferent module) to be loaded as the `NODE_PATH` is searched.\n\nAdditionally, Node.js will search in the following list of GLOBAL\\_FOLDERS:\n\n* 1: `$HOME/.node_modules`\n* 2: `$HOME/.node_libraries`\n* 3: `$PREFIX/lib/node`\n\nWhere `$HOME` is the user's home directory, and `$PREFIX` is the Node.js\nconfigured `node_prefix`.\n\nThese are mostly for historic reasons.\n\nIt is strongly encouraged to place dependencies in the local `node_modules`\nfolder. These will be loaded faster, and more reliably.","summary":"If the `NODE_PATH` environment variable is set to a colon-delimited list of absolute paths, then Node.js will search those paths for modules if they are not found elsewhere.","examples":[],"children":[]},{"kind":"section","id":"the-module-wrapper","name":"The module wrapper","title":"The module wrapper","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"Before a module's code is executed, Node.js will wrap it with a function\nwrapper that looks like the following:\n\n```js\n(function(exports, require, module, __filename, __dirname) {\n// Module code actually lives in here\n});\n```\n\nBy doing this, Node.js achieves a few things:\n\n* It keeps top-level variables (defined with `var`, `const`, or `let`) scoped to\n  the module rather than the global object.\n* It helps to provide some global-looking variables that are actually specific\n  to the module, such as:\n  * The `module` and `exports` objects that the implementor can use to export\n    values from the module.\n  * The convenience variables `__filename` and `__dirname`, containing the\n    module's absolute filename and directory path.","summary":"Before a module's code is executed, Node.js will wrap it with a function wrapper that looks like the following:","examples":[{"language":"js","displayName":null,"code":"(function(exports, require, module, __filename, __dirname) {\n// Module code actually lives in here\n});"}],"children":[]},{"kind":"section","id":"the-module-scope","name":"The module scope","title":"The module scope","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"","summary":"","examples":[],"children":[{"kind":"section","id":"__dirname","name":"__dirname","title":"`__dirname`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.27"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"* Type: {string}\n\nThe directory name of the current module. This is the same as the\n[`path.dirname()`](path.html#pathdirnamepath) of the [`__filename`](#__filename).\n\nExample: running `node example.js` from `/Users/mjr`\n\n```js\nconsole.log(__dirname);\n// Prints: /Users/mjr\nconsole.log(path.dirname(__filename));\n// Prints: /Users/mjr\n```","summary":"The directory name of the current module. This is the same as the `path.dirname()` of the `__filename`.","examples":[{"language":"js","displayName":null,"code":"console.log(__dirname);\n// Prints: /Users/mjr\nconsole.log(path.dirname(__filename));\n// Prints: /Users/mjr"}],"children":[]},{"kind":"section","id":"__filename","name":"__filename","title":"`__filename`","scope":"module","overloadOf":null,"stability":null,"added":["v0.0.1"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"* Type: {string}\n\nThe file name of the current module. This is the current module file's absolute\npath with symlinks resolved.\n\nFor a main program this is not necessarily the same as the file name used in the\ncommand line.\n\nSee [`__dirname`](#__dirname) for the directory name of the current module.\n\nExamples:\n\nRunning `node example.js` from `/Users/mjr`\n\n```js\nconsole.log(__filename);\n// Prints: /Users/mjr/example.js\nconsole.log(__dirname);\n// Prints: /Users/mjr\n```\n\nGiven two modules: `a` and `b`, where `b` is a dependency of\n`a` and there is a directory structure of:\n\n* `/Users/mjr/app/a.js`\n* `/Users/mjr/app/node_modules/b/b.js`\n\nReferences to `__filename` within `b.js` will return\n`/Users/mjr/app/node_modules/b/b.js` while references to `__filename` within\n`a.js` will return `/Users/mjr/app/a.js`.","summary":"The file name of the current module. This is the current module file's absolute path with symlinks resolved.","examples":[{"language":"js","displayName":null,"code":"console.log(__filename);\n// Prints: /Users/mjr/example.js\nconsole.log(__dirname);\n// Prints: /Users/mjr"}],"children":[]},{"kind":"section","id":"exports","name":"exports","title":"`exports`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.12"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"* Type: {Object}\n\nA reference to the `module.exports` that is shorter to type.\nSee the section about the [exports shortcut](#exports-shortcut) for details on when to use\n`exports` and when to use `module.exports`.","summary":"A reference to the `module.exports` that is shorter to type. See the section about the exports shortcut for details on when to use `exports` and when to use `module.exports`.","examples":[],"children":[]},{"kind":"section","id":"module","name":"module","title":"`module`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.16"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"* Type: {module}\n\nA reference to the current module, see the section about the\n[`module` object](#the-module-object). In particular, `module.exports` is used for defining what\na module exports and makes available through `require()`.","summary":"A reference to the current module, see the section about the `module` object. In particular, `module.exports` is used for defining what a module exports and makes available through `require()`.","examples":[],"children":[]},{"kind":"method","id":"requireid","name":"require","title":"`require(id)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.13"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"id","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"module name or path","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"exported module content"}},"description":"Used to import modules, `JSON`, and local files. Modules can be imported\nfrom `node_modules`. Local modules and JSON files can be imported using\na relative path (e.g. `./`, `./foo`, `./bar/baz`, `../foo`) that will be\nresolved against the directory named by [`__dirname`](#__dirname) (if defined) or\nthe current working directory. The relative paths of POSIX style are resolved\nin an OS independent fashion, meaning that the examples above will work on\nWindows in the same way they would on Unix systems.\n\n```js\n// Importing a local module with a path relative to the `__dirname` or current\n// working directory. (On Windows, this would resolve to .\\path\\myLocalModule.)\nconst myLocalModule = require('./path/myLocalModule');\n\n// Importing a JSON file:\nconst jsonData = require('./path/filename.json');\n\n// Importing a module from node_modules or Node.js built-in module:\nconst crypto = require('node:crypto');\n```","summary":"Used to import modules, `JSON`, and local files. Modules can be imported from `node_modules`. Local modules and JSON files can be imported using a relative path (e.g. `./`, `./foo`, `./bar/baz`, `../foo`) that will be resolved against the directory named by `__dirname` (if defined) or the current working directory. The relative paths of POSIX style are resolved in an OS independent fashion, meaning that the examples above will work on Windows in the same way they would on Unix systems.","examples":[{"language":"js","displayName":null,"code":"// Importing a local module with a path relative to the `__dirname` or current\n// working directory. (On Windows, this would resolve to .\\path\\myLocalModule.)\nconst myLocalModule = require('./path/myLocalModule');\n\n// Importing a JSON file:\nconst jsonData = require('./path/filename.json');\n\n// Importing a module from node_modules or Node.js built-in module:\nconst crypto = require('node:crypto');"}],"children":[{"kind":"property","id":"requirecache","name":"cache","title":"`require.cache`","scope":"module","overloadOf":null,"stability":null,"added":["v0.3.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"default":null,"description":"Modules are cached in this object when they are required. By deleting a key\nvalue from this object, the next `require` will reload the module.\nThis does not apply to [native addons](addons.html), for which reloading will result in an\nerror.\n\nAdding or replacing entries is also possible. This cache is checked before\nbuilt-in modules and if a name matching a built-in module is added to the cache,\nonly `node:`-prefixed require calls are going to receive the built-in module.\nUse with care!\n\n```js\nconst assert = require('node:assert');\nconst realFs = require('node:fs');\n\nconst fakeFs = {};\nrequire.cache.fs = { exports: fakeFs };\n\nassert.strictEqual(require('fs'), fakeFs);\nassert.strictEqual(require('node:fs'), realFs);\n```","summary":"Modules are cached in this object when they are required. By deleting a key value from this object, the next `require` will reload the module. This does not apply to native addons, for which reloading will result in an error.","examples":[{"language":"js","displayName":null,"code":"const assert = require('node:assert');\nconst realFs = require('node:fs');\n\nconst fakeFs = {};\nrequire.cache.fs = { exports: fakeFs };\n\nassert.strictEqual(require('fs'), fakeFs);\nassert.strictEqual(require('node:fs'), realFs);"}],"children":[]},{"kind":"property","id":"requireextensions","name":"extensions","title":"`require.extensions`","scope":"module","overloadOf":null,"stability":{"index":"0","description":"Deprecated"},"added":["v0.3.0"],"deprecated":["v0.10.6"],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"default":null,"description":"Instruct `require` on how to handle certain file extensions.\n\nProcess files with the extension `.sjs` as `.js`:\n\n```js\nrequire.extensions['.sjs'] = require.extensions['.js'];\n```\n\n**Deprecated.** In the past, this list has been used to load non-JavaScript\nmodules into Node.js by compiling them on-demand. However, in practice, there\nare much better ways to do this, such as loading modules via some other Node.js\nprogram, or compiling them to JavaScript ahead of time.\n\nAvoid using `require.extensions`. Use could cause subtle bugs and resolving the\nextensions gets slower with each registered extension.","summary":"Instruct `require` on how to handle certain file extensions.","examples":[{"language":"js","displayName":null,"code":"require.extensions['.sjs'] = require.extensions['.js'];"}],"children":[]},{"kind":"property","id":"requiremain","name":"main","title":"`require.main`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.17"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"module | undefined","links":[{"name":"module","href":"modules.html#the-module-object","start":0,"end":6},{"name":"undefined","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#undefined_type","start":9,"end":18}]},"default":null,"description":"The `Module` object representing the entry script loaded when the Node.js\nprocess launched, or `undefined` if the entry point of the program is not a\nCommonJS module.\nSee [\"Accessing the main module\"](#accessing-the-main-module).\n\nIn `entry.js` script:\n\n```js\nconsole.log(require.main);\n```\n\n```bash\nnode entry.js\n```\n\n```js\nModule {\n  id: '.',\n  path: '/absolute/path/to',\n  exports: {},\n  filename: '/absolute/path/to/entry.js',\n  loaded: false,\n  children: [],\n  paths:\n   [ '/absolute/path/to/node_modules',\n     '/absolute/path/node_modules',\n     '/absolute/node_modules',\n     '/node_modules' ] }\n```","summary":"The `Module` object representing the entry script loaded when the Node.js process launched, or `undefined` if the entry point of the program is not a CommonJS module. See \"Accessing the main module\".","examples":[{"language":"js","displayName":null,"code":"console.log(require.main);"},{"language":"bash","displayName":null,"code":"node entry.js"},{"language":"js","displayName":null,"code":"Module {\n  id: '.',\n  path: '/absolute/path/to',\n  exports: {},\n  filename: '/absolute/path/to/entry.js',\n  loaded: false,\n  children: [],\n  paths:\n   [ '/absolute/path/to/node_modules',\n     '/absolute/path/node_modules',\n     '/absolute/node_modules',\n     '/node_modules' ] }"}],"children":[]},{"kind":"method","id":"requireresolverequest-options","name":"resolve","title":"`require.resolve(request[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.3.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v8.9.0"],"prUrl":"https://github.com/nodejs/node/pull/16397","commit":null,"description":"The `paths` option is now supported."}],"signature":{"parameters":[{"name":"request","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The module path to resolve.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"paths","type":{"text":"string[]","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"Paths to resolve module location from. If present, these\npaths are used instead of the default resolution paths, with the exception\nof [GLOBAL\\_FOLDERS](#loading-from-the-global-folders) like `$HOME/.node_modules`, which are\nalways included. Each of these paths is used as a starting point for\nthe module resolution algorithm, meaning that the `node_modules` hierarchy\nis checked from this location.","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":""}},"description":"Use the internal `require()` machinery to look up the location of a module,\nbut rather than loading the module, just return the resolved filename.\n\nIf the module can not be found, a `MODULE_NOT_FOUND` error is thrown.","summary":"Use the internal `require()` machinery to look up the location of a module, but rather than loading the module, just return the resolved filename.","examples":[],"children":[{"kind":"method","id":"requireresolvepathsrequest","name":"paths","title":"`require.resolve.paths(request)`","scope":"module","overloadOf":null,"stability":null,"added":["v8.9.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"request","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The module path whose lookup paths are being retrieved.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"string[] | null","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":11,"end":15}]},"description":""}},"description":"Returns an array containing the paths searched during resolution of `request` or\n`null` if the `request` string references a core module, for example `http` or\n`fs`.","summary":"Returns an array containing the paths searched during resolution of `request` or `null` if the `request` string references a core module, for example `http` or `fs`.","examples":[],"children":[]}]}]}]},{"kind":"section","id":"the-module-object","name":"module","title":"The `module` object","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.16"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"* Type: {Object}\n\nIn each module, the `module` free variable is a reference to the object\nrepresenting the current module. For convenience, `module.exports` is\nalso accessible via the `exports` module-global. `module` is not actually\na global but rather local to each module.","summary":"In each module, the `module` free variable is a reference to the object representing the current module. For convenience, `module.exports` is also accessible via the `exports` module-global. `module` is not actually a global but rather local to each module.","examples":[],"children":[{"kind":"property","id":"modulechildren","name":"children","title":"`module.children`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.16"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"module[]","links":[{"name":"module","href":"modules.html#the-module-object","start":0,"end":6}]},"default":null,"description":"The module objects required for the first time by this one.","summary":"The module objects required for the first time by this one.","examples":[],"children":[]},{"kind":"property","id":"moduleexports","name":"exports","title":"`module.exports`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.16"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"default":null,"description":"The `module.exports` object is created by the `Module` system. Sometimes this is\nnot acceptable; many want their module to be an instance of some class. To do\nthis, assign the desired export object to `module.exports`. Assigning\nthe desired object to `exports` will simply rebind the local `exports` variable,\nwhich is probably not what is desired.\n\nFor example, suppose we were making a module called `a.js`:\n\n```js\nconst EventEmitter = require('node:events');\n\nmodule.exports = new EventEmitter();\n\n// Do some work, and after some time emit\n// the 'ready' event from the module itself.\nsetTimeout(() => {\n  module.exports.emit('ready');\n}, 1000);\n```\n\nThen in another file we could do:\n\n```js\nconst a = require('./a');\na.on('ready', () => {\n  console.log('module \"a\" is ready');\n});\n```\n\nAssignment to `module.exports` must be done immediately. It cannot be\ndone in any callbacks. This does not work:\n\n`x.js`:\n\n```js\nsetTimeout(() => {\n  module.exports = { a: 'hello' };\n}, 0);\n```\n\n`y.js`:\n\n```js\nconst x = require('./x');\nconsole.log(x.a);\n```","summary":"The `module.exports` object is created by the `Module` system. Sometimes this is not acceptable; many want their module to be an instance of some class. To do this, assign the desired export object to `module.exports`. Assigning the desired object to `exports` will simply rebind the local `exports` variable, which is probably not what is desired.","examples":[{"language":"js","displayName":null,"code":"const EventEmitter = require('node:events');\n\nmodule.exports = new EventEmitter();\n\n// Do some work, and after some time emit\n// the 'ready' event from the module itself.\nsetTimeout(() => {\n  module.exports.emit('ready');\n}, 1000);"},{"language":"js","displayName":null,"code":"const a = require('./a');\na.on('ready', () => {\n  console.log('module \"a\" is ready');\n});"},{"language":"js","displayName":null,"code":"setTimeout(() => {\n  module.exports = { a: 'hello' };\n}, 0);"},{"language":"js","displayName":null,"code":"const x = require('./x');\nconsole.log(x.a);"}],"children":[{"kind":"section","id":"exports-shortcut","name":"exports shortcut","title":"`exports` shortcut","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.16"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The `exports` variable is available within a module's file-level scope, and is\nassigned the value of `module.exports` before the module is evaluated.\n\nIt allows a shortcut, so that `module.exports.f = ...` can be written more\nsuccinctly as `exports.f = ...`. However, be aware that like any variable, if a\nnew value is assigned to `exports`, it is no longer bound to `module.exports`:\n\n```js\nmodule.exports.hello = true; // Exported from require of module\nexports = { hello: false };  // Not exported, only available in the module\n```\n\nWhen the `module.exports` property is being completely replaced by a new\nobject, it is common to also reassign `exports`:\n\n```js\nmodule.exports = exports = function Constructor() {\n  // ... etc.\n};\n```\n\nTo illustrate the behavior, imagine this hypothetical implementation of\n`require()`, which is quite similar to what is actually done by `require()`:\n\n```js\nfunction require(/* ... */) {\n  const module = { exports: {} };\n  ((module, exports) => {\n    // Module code here. In this example, define a function.\n    function someFunc() {}\n    exports = someFunc;\n    // At this point, exports is no longer a shortcut to module.exports, and\n    // this module will still export an empty default object.\n    module.exports = someFunc;\n    // At this point, the module will now export someFunc, instead of the\n    // default object.\n  })(module, module.exports);\n  return module.exports;\n}\n```","summary":"The `exports` variable is available within a module's file-level scope, and is assigned the value of `module.exports` before the module is evaluated.","examples":[{"language":"js","displayName":null,"code":"module.exports.hello = true; // Exported from require of module\nexports = { hello: false };  // Not exported, only available in the module"},{"language":"js","displayName":null,"code":"module.exports = exports = function Constructor() {\n  // ... etc.\n};"},{"language":"js","displayName":null,"code":"function require(/* ... */) {\n  const module = { exports: {} };\n  ((module, exports) => {\n    // Module code here. In this example, define a function.\n    function someFunc() {}\n    exports = someFunc;\n    // At this point, exports is no longer a shortcut to module.exports, and\n    // this module will still export an empty default object.\n    module.exports = someFunc;\n    // At this point, the module will now export someFunc, instead of the\n    // default object.\n  })(module, module.exports);\n  return module.exports;\n}"}],"children":[]}]},{"kind":"property","id":"modulefilename","name":"filename","title":"`module.filename`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.16"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"default":null,"description":"The fully resolved filename of the module.","summary":"The fully resolved filename of the module.","examples":[],"children":[]},{"kind":"property","id":"moduleid","name":"id","title":"`module.id`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.16"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"default":null,"description":"The identifier for the module. Typically this is the fully resolved\nfilename.","summary":"The identifier for the module. Typically this is the fully resolved filename.","examples":[],"children":[]},{"kind":"property","id":"moduleispreloading","name":"isPreloading","title":"`module.isPreloading`","scope":"module","overloadOf":null,"stability":null,"added":["v15.4.0","v14.17.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"default":null,"description":"`true` if the module is running during the Node.js preload\nphase.","summary":"","examples":[],"children":[]},{"kind":"property","id":"moduleloaded","name":"loaded","title":"`module.loaded`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.16"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"default":null,"description":"Whether or not the module is done loading, or is in the process of\nloading.","summary":"Whether or not the module is done loading, or is in the process of loading.","examples":[],"children":[]},{"kind":"property","id":"moduleparent","name":"parent","title":"`module.parent`","scope":"module","overloadOf":null,"stability":{"index":"0","description":"Deprecated: Please use [`require.main`](#requiremain) and\n[`module.children`](#modulechildren) instead."},"added":["v0.1.16"],"deprecated":["v14.6.0","v12.19.0"],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"module | null | undefined","links":[{"name":"module","href":"modules.html#the-module-object","start":0,"end":6},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":9,"end":13},{"name":"undefined","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#undefined_type","start":16,"end":25}]},"default":null,"description":"The module that first required this one, or `null` if the current module is the\nentry point of the current process, or `undefined` if the module was loaded by\nsomething that is not a CommonJS module (E.G.: REPL or `import`).","summary":"The module that first required this one, or `null` if the current module is the entry point of the current process, or `undefined` if the module was loaded by something that is not a CommonJS module (E.G.: REPL or `import`).","examples":[],"children":[]},{"kind":"property","id":"modulepath","name":"path","title":"`module.path`","scope":"module","overloadOf":null,"stability":null,"added":["v11.14.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"default":null,"description":"The directory name of the module. This is usually the same as the\n[`path.dirname()`](path.html#pathdirnamepath) of the [`module.id`](#moduleid).","summary":"The directory name of the module. This is usually the same as the `path.dirname()` of the `module.id`.","examples":[],"children":[]},{"kind":"property","id":"modulepaths","name":"paths","title":"`module.paths`","scope":"module","overloadOf":null,"stability":null,"added":["v0.4.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"string[]","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"default":null,"description":"The search paths for the module.","summary":"The search paths for the module.","examples":[],"children":[]},{"kind":"method","id":"modulerequireid","name":"require","title":"`module.require(id)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.1"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"id","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"exported module content"}},"description":"The `module.require()` method provides a way to load a module as if\n`require()` was called from the original module.\n\nIn order to do this, it is necessary to get a reference to the `module` object.\nSince `require()` returns the `module.exports`, and the `module` is typically\n*only* available within a specific module's code, it must be explicitly exported\nin order to be used.","summary":"The `module.require()` method provides a way to load a module as if `require()` was called from the original module.","examples":[],"children":[]}]},{"kind":"section","id":"the-module-object-1","name":"The Module object","title":"The `Module` object","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"This section was moved to\n[Modules: `module` core module](module.html#the-module-object).\n\n* <a id=\"modules_module_builtinmodules\" href=\"module.html#modulebuiltinmodules\">`module.builtinModules`</a>\n* <a id=\"modules_module_createrequire_filename\" href=\"module.html#modulecreaterequirefilename\">`module.createRequire(filename)`</a>\n* <a id=\"modules_module_syncbuiltinesmexports\" href=\"module.html#modulesyncbuiltinesmexports\">`module.syncBuiltinESMExports()`</a>","summary":"This section was moved to Modules: `module` core module.","examples":[],"children":[]},{"kind":"section","id":"source-map-v3-support","name":"Source map v3 support","title":"Source map v3 support","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"This section was moved to\n[Modules: `module` core module](module.html#source-map-support).\n\n* <a id=\"modules_module_findsourcemap_path_error\" href=\"module.html#modulefindsourcemappath\">`module.findSourceMap(path)`</a>\n* <a id=\"modules_class_module_sourcemap\" href=\"module.html#class-modulesourcemap\">Class: `module.SourceMap`</a>\n  * <a id=\"modules_new_sourcemap_payload\" href=\"module.html#new-sourcemappayload--linelengths-\">`new SourceMap(payload)`</a>\n  * <a id=\"modules_sourcemap_payload\" href=\"module.html#sourcemappayload\">`sourceMap.payload`</a>\n  * <a id=\"modules_sourcemap_findentry_linenumber_columnnumber\" href=\"module.html#sourcemapfindentrylineoffset-columnoffset\">`sourceMap.findEntry(lineNumber, columnNumber)`</a>","summary":"This section was moved to Modules: `module` core module.","examples":[],"children":[]}]}