nodejs/node · error
write to standard output already set (--output)\n
Error message
write to standard output already set (--output)\n
What it means
The `--output=PATH` long option shares the `output_set` flag with `--stdout`/`-c`. Specifying `--output=` when `--stdout` (or another `--output=`) was already set returns COMMAND_INVALID, because the two output destinations are mutually exclusive. The dedicated message adds `(--output)` to disambiguate from the bare `--stdout` duplicate error.
Source
Thrown at deps/brotli/c/tools/brotli.c:655
if (lgwin_set) {
fprintf(stderr, "lgwin parameter already set\n");
return COMMAND_INVALID;
}
lgwin_set = ParseInt(value, 0,
BROTLI_LARGE_MAX_WINDOW_BITS, ¶ms->lgwin);
if (!lgwin_set) {
fprintf(stderr, "error parsing lgwin value [%s]\n", value);
return COMMAND_INVALID;
}
if (params->lgwin != 0 && params->lgwin < BROTLI_MIN_WINDOW_BITS) {
fprintf(stderr,
"lgwin parameter (%d) smaller than the minimum (%d)\n",
params->lgwin, BROTLI_MIN_WINDOW_BITS);
return COMMAND_INVALID;
}
} else if (strncmp("output", arg, key_len) == 0) {
if (output_set) {
fprintf(stderr,
"write to standard output already set (--output)\n");
return COMMAND_INVALID;
}
params->output_path = value;
} else if (strncmp("quality", arg, key_len) == 0) {
if (quality_set) {
fprintf(stderr, "quality already set\n");
return COMMAND_INVALID;
}
quality_set = ParseInt(value, BROTLI_MIN_QUALITY,
BROTLI_MAX_QUALITY, ¶ms->quality);
if (!quality_set) {
fprintf(stderr, "error parsing quality value [%s]\n", value);
return COMMAND_INVALID;
}
} else if (strncmp("suffix", arg, key_len) == 0) {
if (suffix_set) {
fprintf(stderr, "suffix already set\n");View on GitHub (pinned to 1b2de5e052)
Solutions
- Choose one destination: either `--output=PATH` or `--stdout`/`-c`, not both.
- Inspect aliases and `BROTLI_OPTS` for hidden `-c`.
- If using `--output=`, remove any prior `-c`/`--stdout` and any prior `--output=`.
Example fix
# before brotli -c --output=out.br input.txt # after brotli --output=out.br input.txt
Defensive patterns
Strategy: validation
Validate before calling
# Enforce mutual exclusion of --output= with --stdout/-c and itself.
count=0
for a in "$@"; do
case "$a" in
--output=*) count=$((count+1));;
--stdout|-c) count=$((count+1));;
esac
done
[ "$count" -gt 1 ] && { echo 'output destination conflict' >&2; exit 2; } Prevention
- Decide output destination (file vs stdout) once, before constructing the command.
- Avoid `alias brotli='brotli -c'`; if you must, never combine with `--output=`.
- Remember also that `--output=` cannot be used with multiple input files (later parser check).
When it happens
Trigger: Invoking `brotli -c --output=out file`, `brotli --stdout --output=out file`, or `--output=a --output=b`.
Common situations: Aliases that default to `-c` (stdout) colliding with explicit `--output=`; CI scripts that pipe to stdout for logging while a build step sets an output file; copy-paste assembling two snippets.
Related errors
- write to standard output already set
- write to standard output already set (-o)\n
- write to standard output already set\n
- command already set when parsing --test\n
- too many options passed
AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13).
Data as JSON: /api/errors/630d48eb17739143.
Report an issue: GitHub.