Skip to content

Commit

Permalink
doc: add require.main to require properties
Browse files Browse the repository at this point in the history
`require.main` was documented in a non-standard way.

With this PR, the previous section is left as is
to not break all the possible link references
inside and outside Node.js docs.

A standard section is added to the `require` properties
with a reference to the old description.

PR-URL: #19573
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
  • Loading branch information
vsemozhetbyt authored and targos committed Mar 27, 2018
1 parent 1e8ece1 commit 4532a89
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions doc/api/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4532a89

Please sign in to comment.