nodejs/node · error

write to standard output already set\n

Error message

write to standard output already set\n

What it means

The `--stdout` (alias `-c`) flag directs compressed/decompressed output to standard output instead of a file. The parser uses `output_set` to enforce single specification; a second occurrence is rejected with COMMAND_INVALID. Note `output_set` is shared with `--output=`, so `--stdout` and `--output=` are also mutually exclusive.

Source

Thrown at deps/brotli/c/tools/brotli.c:570

        params->copy_stat = BROTLI_FALSE;
      } else if (strcmp("rm", arg) == 0) {
        if (keep_set) {
          fprintf(stderr, "argument --rm / -j or --keep / -k already set\n");
          return COMMAND_INVALID;
        }
        keep_set = BROTLI_TRUE;
        params->junk_source = BROTLI_TRUE;
      } else if (strcmp("squash", arg) == 0) {
        if (squash_set) {
          fprintf(stderr, "argument --squash / -s already set\n");
          return COMMAND_INVALID;
        }
        squash_set = BROTLI_TRUE;
        params->reject_uncompressible = BROTLI_TRUE;
        continue;
      } else if (strcmp("stdout", arg) == 0) {
        if (output_set) {
          fprintf(stderr, "write to standard output already set\n");
          return COMMAND_INVALID;
        }
        output_set = BROTLI_TRUE;
        params->write_to_stdout = BROTLI_TRUE;
      } else if (strcmp("test", arg) == 0) {
        if (command_set) {
          fprintf(stderr, "command already set when parsing --test\n");
          return COMMAND_INVALID;
        }
        command_set = BROTLI_TRUE;
        command = COMMAND_TEST_INTEGRITY;
      } else if (strcmp("verbose", arg) == 0) {
        if (params->verbosity > 0) {
          fprintf(stderr, "argument --verbose / -v already set\n");
          return COMMAND_INVALID;
        }
        params->verbosity = 1;
      } else if (strcmp("version", arg) == 0) {

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Remove the duplicate; use exactly one of `--stdout`/`-c` or `--output=PATH`.
  2. If you need file output, drop `--stdout` and use `--output=`.
  3. Inspect `alias brotli` and any `BROTLI_OPTS` env var for stray `-c`.

Example fix

# before
brotli -c --stdout input.txt.br
# after
brotli -c input.txt.br
Defensive patterns

Strategy: validation

Validate before calling

# --stdout/-c and --output= share one slot; reject conflicts and duplicates.
out_re='(^|[[:space:]])(--stdout|-c)([[:space:]]|$)'
occ=0
for a in "$@"; do
  case "$a" in
    --stdout|-c) occ=$((occ+1));;
    --output=*) occ=$((occ+1));;
  esac
done
[ "$occ" -gt 1 ] && { echo 'multiple output destinations' >&2; exit 2; }

Prevention

When it happens

Trigger: Invoking `brotli --stdout --stdout file`, `brotli -c --output=out file`, or piping in a script that adds `-c` while a default alias already sets it.

Common situations: Shell aliases (e.g. `alias brotli='brotli -c'`) colliding with explicit output flags; piping scripts that always want stdout but layer flags from multiple sources.

Related errors


AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13). Data as JSON: /api/errors/f81f59ccfbe81c60. Report an issue: GitHub.