{"record":{"id":"a43708acafd37cdb","repo":"denoland/deno","slug":"cannot-use-output-with-multiple-input-files-use","errorCode":null,"errorMessage":"Cannot use --output with multiple input files. Use --outdir instead.","messagePattern":"Cannot use --output with multiple input files\\. Use --outdir instead\\.","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"cli/tools/transpile.rs","lineNumber":37,"sourceCode":"use sys_traits::PathsInErrorsExt;\n\nuse crate::args::Flags;\nuse crate::args::SourceMapMode;\nuse crate::args::TranspileFlags;\nuse crate::factory::CliFactory;\n\npub async fn transpile(\n  flags: Arc<Flags>,\n  transpile_flags: TranspileFlags,\n) -> Result<(), AnyError> {\n  let files = &transpile_flags.files;\n\n  if files.is_empty() {\n    anyhow::bail!(\"No input files specified\");\n  }\n\n  if files.len() > 1 && transpile_flags.output.is_some() {\n    anyhow::bail!(\n      \"Cannot use --output with multiple input files. Use --outdir instead.\"\n    );\n  }\n\n  if transpile_flags.declaration\n    && transpile_flags.output.is_none()\n    && transpile_flags.output_dir.is_none()\n  {\n    anyhow::bail!(\n      \"Cannot use --declaration without --output or --outdir. Declaration files must be written to disk.\"\n    );\n  }\n\n  let is_stdout_mode = files.len() == 1\n    && transpile_flags.output.is_none()\n    && transpile_flags.output_dir.is_none();\n\n  if is_stdout_mode","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/cli/tools/transpile.rs#L19-L55","documentation":"`--output` (-o) writes a single named file, so it accepts exactly one input. When `files.len() > 1` and `--output` is set, the tool rejects the combination and points at `--outdir`, which emits one output per input while preserving relative structure.","triggerScenarios":"`deno transpile a.ts b.ts -o out.js` — two or more input files combined with a set `--output`.","commonSituations":"Adding a second source file to an existing one-file command that already used -o; build scripts that append inputs dynamically but keep a fixed output filename.","solutions":["Use --outdir instead: `deno transpile a.ts b.ts --outdir dist`","Or keep -o and transpile each file in its own invocation: `for f in a.ts b.ts; do deno transpile \"$f\" -o \"dist/$(basename \"${f%.ts}\").js\"; done`","If the inputs really are one module, merge them into a single entry file first"],"exampleFix":"# before\ndeno transpile src/a.ts src/b.ts --output dist/bundle.js\n# after\ndeno transpile src/a.ts src/b.ts --outdir dist","handlingStrategy":"validation","validationCode":"# bash: route based on input count\nif [ \"$#\" -gt 1 ]; then deno transpile \"$@\" --outdir dist; else deno transpile \"$@\" --output dist/out.js; fi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default build scripts to --outdir; reserve -o for single-file one-offs","When appending new inputs to a command line, re-check whether --output is still valid","Treat one-input-per-output as the invariant and encode it in the wrapper script"],"tags":["cli","transpile","flags","outdir"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}