Skip to content

Commit 5eaef7b

Browse files
reasonablytallTrott
authored andcommitted
doc: describe NODE_OPTIONS interop w/cmd line opts
Fixes #28910 PR-URL: #28928 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent e6c2052 commit 5eaef7b

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

doc/api/cli.md

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -950,16 +950,35 @@ When set to `1`, process warnings are silenced.
950950
added: v8.0.0
951951
-->
952952

953-
A space-separated list of command line options. `options...` are interpreted as
954-
if they had been specified on the command line before the actual command line
955-
(so they can be overridden). Node.js will exit with an error if an option
956-
that is not allowed in the environment is used, such as `-p` or a script file.
953+
A space-separated list of command line options. `options...` are interpreted
954+
before command line options, so command line options will override or
955+
compound after anything in `options...`. Node.js will exit with an error if
956+
an option that is not allowed in the environment is used, such as `-p` or a
957+
script file.
957958

958-
In case an option value happens to contain a space (for example a path listed in
959-
`--require`), it must be escaped using double quotes. For example:
959+
In case an option value happens to contain a space (for example a path listed
960+
in `--require`), it must be escaped using double quotes. For example:
960961

961962
```bash
962-
--require "./my path/file.js"
963+
NODE_OPTIONS='--require "./my path/file.js"'
964+
```
965+
966+
A singleton flag passed as a command line option will override the same flag
967+
passed into `NODE_OPTIONS`:
968+
969+
```bash
970+
# The inspector will be available on port 5555
971+
NODE_OPTIONS='--inspect=localhost:4444' node --inspect=localhost:5555
972+
```
973+
974+
A flag that can be passed multiple times will be treated as if its
975+
`NODE_OPTIONS` instances were passed first, and then its command line
976+
instances afterwards:
977+
978+
```bash
979+
NODE_OPTIONS='--require "./a.js"' node --require "./b.js"
980+
# is equivalent to:
981+
node --require "./a.js" --require "./b.js"
963982
```
964983

965984
Node.js options that are allowed are:

0 commit comments

Comments
 (0)