denoland/deno · error
--output is not supported with HTML entrypoints; use…
Error message
--output is not supported with HTML entrypoints; use --outdir
What it means
`deno bundle` rejects the combination of `--output` (a single output path) with HTML entrypoints. HTML bundling emits multiple files into a directory (JS with content hash, `.js.map`, patched HTML), so a single output path cannot represent the result; the error tells you to use `--outdir` instead.
Solutions
- Replace `--output` with `--outdir`: `deno bundle --outdir=dist index.html`
- If a single JS file is genuinely required, bundle the script module directly and keep HTML out of the entrypoints
Example fix
# before deno bundle --output=app.js index.html # after deno bundle --outdir=dist index.html
Defensive patterns
Strategy: validation
Validate before calling
// Wrapper: reject --output when any entry ends with .html
const entries = Deno.args.filter((a) => !a.startsWith("-"));
if (
entries.some((e) => e.endsWith(".html")) &&
Deno.args.some((a) => a.startsWith("--output") || a === "-o")
) {
throw new Error("use --outdir, not --output, when bundling HTML");
} Prevention
- Map HTML bundles to --outdir in all build scripts
- Reserve --output for single-file JS bundles
When it happens
Trigger: `deno bundle --output=app.js index.html` — any run with at least one HTML entrypoint plus the `--output` flag.
Common situations: Build scripts ported from JS bundling that hard-code `--output`; muscle memory from esbuild's `--outfile` flag.
Related errors
- --outdir is required when bundling HTML entrypoints
- failed to locate output for HTML entry
- Deno.bundle() is not available in compiled binaries (`deno…
- Entry point must be a file
- ERR_WORKER_INVALID_EXEC_ARGV
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/40eeb22375dbc912.
Report an issue: GitHub.
Appendix: 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 9ad36f7a2c)