From bdd442fe35496f1cfc588e9e7148d8cb09edb2b9 Mon Sep 17 00:00:00 2001 From: Alex Aubuchon Date: Thu, 1 Aug 2019 11:04:47 -0700 Subject: [PATCH] doc: describe NODE_OPTIONS interop w/cmd line opts Fixes https://github.com/nodejs/node/issues/28910 PR-URL: https://github.com/nodejs/node/pull/28928 Reviewed-By: Luigi Pinca Reviewed-By: Roman Reiss Reviewed-By: Rich Trott Reviewed-By: Colin Ihrig --- doc/api/cli.md | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/doc/api/cli.md b/doc/api/cli.md index 1e765df93f8f3c..5a4fe9992899df 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -961,16 +961,35 @@ When set to `1`, process warnings are silenced. added: v8.0.0 --> -A space-separated list of command line options. `options...` are interpreted as -if they had been specified on the command line before the actual command line -(so they can be overridden). Node.js will exit with an error if an option -that is not allowed in the environment is used, such as `-p` or a script file. +A space-separated list of command line options. `options...` are interpreted +before command line options, so command line options will override or +compound after anything in `options...`. Node.js will exit with an error if +an option that is not allowed in the environment is used, such as `-p` or a +script file. -In case an option value happens to contain a space (for example a path listed in -`--require`), it must be escaped using double quotes. For example: +In case an option value happens to contain a space (for example a path listed +in `--require`), it must be escaped using double quotes. For example: ```bash ---require "./my path/file.js" +NODE_OPTIONS='--require "./my path/file.js"' +``` + +A singleton flag passed as a command line option will override the same flag +passed into `NODE_OPTIONS`: + +```bash +# The inspector will be available on port 5555 +NODE_OPTIONS='--inspect=localhost:4444' node --inspect=localhost:5555 +``` + +A flag that can be passed multiple times will be treated as if its +`NODE_OPTIONS` instances were passed first, and then its command line +instances afterwards: + +```bash +NODE_OPTIONS='--require "./a.js"' node --require "./b.js" +# is equivalent to: +node --require "./a.js" --require "./b.js" ``` Node.js options that are allowed are: