diff --git a/doc/api/modules.md b/doc/api/modules.md index 2930f2af68e095..aa03b414c35dfa 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 + + +* {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 +``` + + +```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])