Commit 16c0bea 1 parent 014d483 commit 16c0bea Copy full SHA for 16c0bea
File tree 1 file changed +5
-5
lines changed
1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -74,9 +74,8 @@ run directly by testing `require.main === module`.
74
74
For a file ` foo.js ` , this will be ` true ` if run via ` node foo.js ` , but
75
75
` false ` if run by ` require('./foo') ` .
76
76
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.
80
79
81
80
## Package manager tips
82
81
@@ -718,10 +717,11 @@ extensions gets slower with each registered extension.
718
717
added: v0.1.17
719
718
-->
720
719
721
- * {module}
720
+ * {module | undefined }
722
721
723
722
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.
725
725
See [ "Accessing the main module"] ( #accessing-the-main-module ) .
726
726
727
727
In ` entry.js ` script:
You can’t perform that action at this time.
0 commit comments