swc-project/swc · error
`deno bundle` failed with status code {}
Error message
`deno bundle` failed with status code {} What it means
dbg-swc's bundle helper shells out to the deno CLI ('deno bundle <entry_url>'), inheriting stderr so deno's own error output reaches the terminal, and bails with the child's status code when it exits non-zero. The failure comes from deno, not from SWC: module download failures, an unreachable or mistyped entry URL, compile errors in the dependency graph, or a deno binary that no longer supports the bundle subcommand (it was removed in Deno 2).
Source
Thrown at crates/dbg-swc/src/bundle.rs:22
};
use anyhow::{bail, Context, Result};
use swc_common::{FileName, SourceMap};
use crate::util::{parse_js, wrap_task, ModuleRecord};
pub fn bundle(cm: Arc<SourceMap>, entry_url: &str) -> Result<ModuleRecord> {
wrap_task(|| {
let mut cmd = Command::new("deno");
cmd.arg("bundle");
cmd.arg(entry_url);
cmd.stderr(Stdio::inherit());
let output = cmd.output().context("failed to invoke `deno bundle`")?;
if !output.status.success() {
bail!("`deno bundle` failed with status code {}", output.status);
}
let code =
String::from_utf8(output.stdout).context("deno bundle emitted non-utf8 output")?;
let fm = cm.new_source_file(FileName::Anon.into(), code);
parse_js(fm).context("failed to parse js filed emitted by `deno bundle`")
})
.with_context(|| format!("failed to bundle `{entry_url}`"))
}
View on GitHub (pinned to 5176682b65)
Solutions
- Run 'deno bundle <entry_url>' manually in the same shell - deno's stderr shows the true reason
- Check 'deno --version': 'deno bundle' was removed in Deno 2; pin Deno 1.x for this helper
- Ensure network/proxy access and DENO_AUTH_TOKENS for private modules, or vendor dependencies locally
- Verify the entry URL resolves (curl it) before invoking dbg-swc
Example fix
# before: system deno is 2.x, `deno bundle` is gone $ deno --version deno 2.0.0 # after: pin a 1.x deno for this workflow $ asdf install deno 1.46.3 $ asdf local deno 1.46.3 $ deno bundle ./entry.ts # works, dbg-swc bundle proceeds
Defensive patterns
Strategy: retry
Validate before calling
use std::process::Command;
fn deno_available() -> bool {
Command::new("deno")
.arg("--version")
.output()
.map(|o| o.status.success())
.unwrap_or(false)
}
fn entry_reachable(url: &str) -> bool {
// cheap check before shelling out
url::Url::parse(url).is_ok()
} Try / catch
fn bundle_retry(cm: Arc<SourceMap>, url: &str) -> Result<ModuleRecord> {
let mut last = None;
for attempt in 0..3 {
match bundle(cm.clone(), url) {
Ok(r) => return Ok(r),
Err(e) => {
let msg = format!("{e:#}");
if msg.contains("failed to invoke") || msg.contains("removed") {
return Err(e); // binary missing / unsupported subcommand: do not retry
}
eprintln!("deno bundle attempt {} failed: {}", attempt + 1, msg);
last = Some(e);
}
}
}
Err(last.expect("at least one attempt"))
} Prevention
- Pin Deno 1.x in CI - 'deno bundle' does not exist in Deno 2
- Vendor or cache remote dependencies (DENO_DIR, lockfile) so bundles work offline
- Verify the entry URL with a plain fetch/curl before invoking dbg-swc
When it happens
Trigger: Running the dbg-swc bundle command for an entry URL deno cannot fetch or compile; the message shows the raw exit status (deno uses 101 for uncaught errors, 1 for general failure).
Common situations: Offline or proxied sandboxes where deno cannot download remote modules; environments that upgraded to Deno 2.x where 'deno bundle' no longer exists; remote specifiers behind auth (missing DENO_AUTH_TOKENS); typos in the entry URL.
Related errors
- `npm run build` failed
- failed to run terser
- failed to run esbuild
- prettier failed
- No `.js` or `.jsx` files found in `{}`
AI-assisted analysis of swc-project/swc@5176682b65 (2026-08-17).
Data as JSON: /api/errors/161e62a80b59b37f.
Report an issue: GitHub.