denoland/deno · error
--output is not supported with HTML entrypoints; use --outdi
Error message
--output is not supported with HTML entrypoints; use --outdir
What it means
--output/-o names a single output file, which cannot hold the multi-file output an HTML entrypoint produces (html + js + css + maps). When any entrypoint is HTML and bundle_flags.output_path is Some, the CLI rejects the combination and points at --outdir (cli/tools/bundle/mod.rs:152-156).
Source
Thrown at cli/tools/bundle/mod.rs:153
let graph = plugin_handler.module_graph_container.graph();
let mut fully_resolved_roots = IndexSet::with_capacity(graph.roots.len());
for root in &graph.roots {
fully_resolved_roots.insert(graph.resolve(root).clone());
}
*plugin_handler.resolved_roots.write() = Arc::new(fully_resolved_roots);
Ok(BundlerInput::Entrypoints(
roots.into_iter().map(|e| ("".into(), e.into())).collect(),
))
} else {
// require an outdir when any HTML is present
if bundle_flags.output_dir.is_none() {
return Err(deno_core::anyhow::anyhow!(
"--outdir is required when bundling HTML entrypoints",
));
}
if bundle_flags.output_path.is_some() {
return Err(deno_core::anyhow::anyhow!(
"--output is not supported with HTML entrypoints; use --outdir",
));
}
// Prepare HTML pages and temp entry modules
let mut html_pages = Vec::new();
let mut to_cache_urls = Vec::new();
let mut entries: Vec<(String, String)> = Vec::new();
let virtual_modules = Arc::new(VirtualModules::new());
for html_path in &html_paths {
let entry = html::load_html_entrypoint(
init_cwd,
html_path,
plugin_handler
.is_runtime_api
.then_some(&plugin_handler.permissions),
)?;View on GitHub (pinned to 89f33cbef2)
Solutions
- Replace --output <file> with --outdir <dir>: 'deno bundle --outdir dist index.html'
- If you truly need one JS file, bundle the page's script entry directly instead of the HTML
Example fix
# before deno bundle --output dist/app.js index.html # after deno bundle --outdir dist index.html
Defensive patterns
Strategy: validation
Validate before calling
#!/usr/bin/env bash # Reject the --output + HTML combination before spawning deno entry="$1"; shift case "$entry" in *.html|*.htm) case " $* " in *' --output '*|*' -o '*) echo 'use --outdir, not --output, for HTML entrypoints'; exit 2;; esac;; esac deno bundle "$entry" "$@"
Type guard
function usesSingleOutput(flags: string[]): boolean {
return flags.includes('--output') || flags.includes('-o');
} Prevention
- Migrate legacy 'deno bundle -o file.js entry.ts' commands to --outdir when adding HTML entries
- Audit CI configs for hardcoded --output flags before adopting HTML bundling
When it happens
Trigger: 'deno bundle --output dist/app.js index.html' (or the -o short form) with an HTML entry among the inputs; build scripts reusing a JS-bundle command line against an HTML page.
Common situations: Porting an existing 'deno bundle -o app.js src/main.ts' pipeline to HTML entrypoints; CI configs with a hardcoded --output flag.
Related errors
- --outdir is required when bundling HTML entrypoints
- failed to locate output for HTML entry '{}'; {js_entry_name}
- Unexpected 'name' field in options, bench name is already pr
- The bench function must have a name
- Unexpected 'fn' field in options, bench function is already
AI-assisted analysis of denoland/deno@89f33cbef2 (2026-08-16).
Data as JSON: /api/errors/40eeb22375dbc912.
Report an issue: GitHub.