denoland/deno · error
build failed (exit code: )
Error message
{} build failed (exit code: {}) What it means
`deno desktop` detects the web framework in the project and delegates the build to the framework's own build command (e.g. `vite build`, `next build`) via std::process::Command. This error reports that the child build process exited with a non-zero status; the actual failure reason was printed by the framework's own tooling to the console just before this message.
Solutions
- Run the framework's build directly (e.g. `npm run build` or `npx vite build`) to see the full error output and fix what it reports
- Install dependencies first (`npm install` or `deno install`), then retry `deno desktop`
- Verify required build-time environment variables and the Node.js version the framework needs
Example fix
# before deno desktop # Next.js build failed (exit code: 1) # after npm run build # shows the real error (e.g. type error in src/app/page.tsx) # fix the reported error, then: deno desktop
Defensive patterns
Strategy: validation
Validate before calling
# prove the framework build passes before invoking deno desktop: npm install && npm run build # or: npx vite build / npm run build # only then: deno desktop
Try / catch
Wrap `deno desktop` invocation; on failure parse 'build failed (exit code: N)', then re-run the raw build command (`npm run build`) to surface the underlying errors for triage.
Prevention
- Make `npm run build` (or the framework's build) green locally before `deno desktop`
- Install dependencies as a separate, earlier step in scripts and Dockerfiles
- Provide required build-time env vars in both local and CI environments
When it happens
Trigger: Any framework build failure: TypeScript/ESLint errors inside the project, missing dependencies (node_modules absent), missing build-time env vars, out-of-memory, or a Node.js version incompatible with the framework. The spawn itself succeeded (a spawn failure would give the 'Failed to run build command' context instead); the process ran and returned a failing exit code.
Common situations: Running `deno desktop` before installing dependencies (npm install / deno install); projects whose `npm run build` fails on type errors; missing .env values needed at build time; local Node version differs from the one CI pins.
Related errors
- could not find ' ' backend binary under (set via )
- dev server exited without printing a URL
- no pinned SHA-256 for
- SvelteKit detected, but no adapter that `deno desktop` can…
- app bundle has no name
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/62e7832067225f67.
Report an issue: GitHub.
Appendix: source
Thrown at cli/tools/framework.rs:148
dir: &Path,
) -> Result<(), AnyError> {
let Some(build_cmd) = &detection.build_command else {
return Ok(());
};
log::info!(
"{} {} project...",
deno_terminal::colors::green("Building"),
detection.name,
);
let status = std::process::Command::new(&build_cmd[0])
.args(&build_cmd[1..])
.current_dir(dir)
.status()
.with_context(|| {
format!("Failed to run build command: {}", build_cmd.join(" "))
})?;
if !status.success() {
deno_core::anyhow::bail!(
"{} build failed (exit code: {})",
detection.name,
status.code().unwrap_or(-1)
);
}
Ok(())
}
/// Detect a web framework in the given directory.
///
/// Detection priority:
/// 1. Config-file based detection (highest priority)
/// 2. Package.json dependency-based detection
/// 3. deno.json import-based detection
pub fn detect_framework(
dir: &Path,
) -> Result<Option<FrameworkDetection>, AnyError> {
// --- Config-file based detection (highest priority) ---View on GitHub (pinned to 9ad36f7a2c)