denoland/deno · error · anyhow::Error

Cannot use --source-map separate when outputting to stdout.

Error message

Cannot use --source-map separate when outputting to stdout. Use --output or --outdir, or use --source-map inline instead.

What it means

`--source-map separate` writes a .map file next to the output file. In stdout mode (exactly one input, no `--output`, no `--outdir`) there is no output path to anchor the .map file, so the combination is rejected with suggestions: write to disk or inline the map.

Source

Thrown at cli/tools/transpile.rs:58

  }

  if transpile_flags.declaration
    && transpile_flags.output.is_none()
    && transpile_flags.output_dir.is_none()
  {
    anyhow::bail!(
      "Cannot use --declaration without --output or --outdir. Declaration files must be written to disk."
    );
  }

  let is_stdout_mode = files.len() == 1
    && transpile_flags.output.is_none()
    && transpile_flags.output_dir.is_none();

  if is_stdout_mode
    && matches!(transpile_flags.source_map, SourceMapMode::Separate)
  {
    anyhow::bail!(
      "Cannot use --source-map separate when outputting to stdout. Use --output or --outdir, or use --source-map inline instead."
    );
  }

  let factory = CliFactory::from_flags(flags.clone());
  let cli_options = factory.cli_options()?;
  let cwd = cli_options.initial_cwd();
  let real_sys = factory.sys();
  let sys = real_sys.with_paths_in_errors();

  let source_map_option = match transpile_flags.source_map {
    SourceMapMode::None => SourceMapOption::None,
    SourceMapMode::Inline => SourceMapOption::Inline,
    SourceMapMode::Separate => SourceMapOption::Separate,
  };

  // Resolve transpile options from deno.json compilerOptions
  let compiler_options_resolver = factory.compiler_options_resolver()?;

View on GitHub (pinned to 89f33cbef2)

Solutions

  1. Switch to inline maps: `deno transpile mod.ts --source-map inline`
  2. Or write output to disk: add --output or --outdir so the .map file has a sibling path
  3. Or disable maps entirely: `--source-map none`

Example fix

# before
deno transpile mod.ts --source-map separate | node -
# after
deno transpile mod.ts --source-map inline | node -
Defensive patterns

Strategy: validation

Validate before calling

# bash: pick a source-map mode compatible with stdout piping
if [ -t 1 ]; then deno transpile "$@" --source-map separate --outdir dist; else deno transpile "$@" --source-map inline; fi

Prevention

When it happens

Trigger: `deno transpile mod.ts --source-map separate` where mod.ts is the only input and neither --output nor --outdir is set.

Common situations: Piping transpiled output into another tool (`deno transpile mod.ts | node -`) while keeping the default separate source-map mode; debug setups that need stack maps in a pipeline.

Related errors


AI-assisted analysis of denoland/deno@89f33cbef2 (2026-08-16). Data as JSON: /api/errors/6e35efd084c7d8c5. Report an issue: GitHub.