Skip to content

Commit f571b29

Browse files
aduh95addaleax
authored andcommitted
doc: deprecate process.mainModule
PR-URL: #32232 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 6ade42b commit f571b29

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

doc/api/deprecations.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2617,6 +2617,24 @@ async function openAndClose() {
26172617
}
26182618
```
26192619
2620+
<a id="DEP0138"></a>
2621+
### DEP0138: `process.mainModule`
2622+
<!-- YAML
2623+
changes:
2624+
- version: REPLACEME
2625+
pr-url: https://github.com/nodejs/node/pull/32232
2626+
description: Documentation-only deprecation.
2627+
-->
2628+
2629+
Type: Documentation-only
2630+
2631+
[`process.mainModule`][] is a CommonJS-only feature while `process` global
2632+
object is shared with non-CommonJS environment. Its use within ECMAScript
2633+
modules is unsupported.
2634+
2635+
It is deprecated in favor of [`require.main`][], because it serves the same
2636+
purpose and is only available on CommonJS environment.
2637+
26202638
[`--pending-deprecation`]: cli.html#cli_pending_deprecation
26212639
[`--throw-deprecation`]: cli.html#cli_throw_deprecation
26222640
[`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size
@@ -2674,8 +2692,10 @@ async function openAndClose() {
26742692
[`os.networkInterfaces()`]: os.html#os_os_networkinterfaces
26752693
[`os.tmpdir()`]: os.html#os_os_tmpdir
26762694
[`process.env`]: process.html#process_process_env
2695+
[`process.mainModule`]: process.html#process_process_mainmodule
26772696
[`punycode`]: punycode.html
26782697
[`require.extensions`]: modules.html#modules_require_extensions
2698+
[`require.main`]: modules.html#modules_accessing_the_main_module
26792699
[`request.socket`]: http.html#http_request_socket
26802700
[`request.connection`]: http.html#http_request_connection
26812701
[`response.socket`]: http.html#http_response_socket

doc/api/process.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,8 +1499,11 @@ debugger. See [Signal Events][].
14991499
## `process.mainModule`
15001500
<!-- YAML
15011501
added: v0.1.17
1502+
deprecated: REPLACEME
15021503
-->
15031504

1505+
> Stability: 0 - Deprecated: Use [`require.main`][] instead.
1506+
15041507
* {Object}
15051508

15061509
The `process.mainModule` property provides an alternative way of retrieving

0 commit comments

Comments
 (0)