summaryrefslogtreecommitdiff
path: root/doc/api/modules.md
diff options
context:
space:
mode:
Diffstat (limited to 'doc/api/modules.md')
-rw-r--r--doc/api/modules.md37
1 files changed, 37 insertions, 0 deletions
diff --git a/doc/api/modules.md b/doc/api/modules.md
index 2930f2af68..aa03b414c3 100644
--- a/doc/api/modules.md
+++ b/doc/api/modules.md
@@ -600,6 +600,43 @@ filename scales linearly with the number of registered extensions.
In other words, adding extensions slows down the module loader and
should be discouraged.
+#### require.main
+<!-- YAML
+added: v0.1.17
+-->
+
+* {Object}
+
+The `Module` object representing the entry script loaded when the Node.js
+process launched.
+See ["Accessing the main module"](#modules_accessing_the_main_module).
+
+In `entry.js` script:
+
+```js
+console.log(require.main);
+```
+
+```sh
+node entry.js
+```
+
+<!-- eslint-skip -->
+```js
+Module {
+ id: '.',
+ exports: {},
+ parent: null,
+ filename: '/absolute/path/to/entry.js',
+ loaded: false,
+ children: [],
+ paths:
+ [ '/absolute/path/to/node_modules',
+ '/absolute/path/node_modules',
+ '/absolute/node_modules',
+ '/node_modules' ] }
+```
+
#### require.resolve(request[, options])
<!-- YAML
added: v0.3.0