Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 16c0bea

Browse filesBrowse files
aduh95targos
authored andcommitted
doc: document that require.main may be undefined
PR-URL: #41384 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Adrian Estrada <edsadr@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
1 parent 014d483 commit 16c0bea
Copy full SHA for 16c0bea

File tree

Expand file treeCollapse file tree

1 file changed

+5
-5
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-5
lines changed
Open diff view settings
Collapse file

‎doc/api/modules.md‎

Copy file name to clipboardExpand all lines: doc/api/modules.md
+5-5Lines changed: 5 additions & 5 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,8 @@ run directly by testing `require.main === module`.
7474
For a file `foo.js`, this will be `true` if run via `node foo.js`, but
7575
`false` if run by `require('./foo')`.
7676

77-
Because `module` provides a `filename` property (normally equivalent to
78-
`__filename`), the entry point of the current application can be obtained
79-
by checking `require.main.filename`.
77+
When the entry point is not a CommonJS module, `require.main` is `undefined`,
78+
and the main module is out of reach.
8079

8180
## Package manager tips
8281

@@ -718,10 +717,11 @@ extensions gets slower with each registered extension.
718717
added: v0.1.17
719718
-->
720719

721-
* {module}
720+
* {module | undefined}
722721

723722
The `Module` object representing the entry script loaded when the Node.js
724-
process launched.
723+
process launched, or `undefined` if the entry point of the program is not a
724+
CommonJS module.
725725
See ["Accessing the main module"](#accessing-the-main-module).
726726

727727
In `entry.js` script:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.