{"record":{"id":"62e7832067225f67","repo":"denoland/deno","slug":"build-failed-exit-code","errorCode":null,"errorMessage":"{} build failed (exit code: {})","messagePattern":"(.+?) build failed \\(exit code: (.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/tools/framework.rs","lineNumber":148,"sourceCode":"  dir: &Path,\n) -> Result<(), AnyError> {\n  let Some(build_cmd) = &detection.build_command else {\n    return Ok(());\n  };\n  log::info!(\n    \"{} {} project...\",\n    deno_terminal::colors::green(\"Building\"),\n    detection.name,\n  );\n  let status = std::process::Command::new(&build_cmd[0])\n    .args(&build_cmd[1..])\n    .current_dir(dir)\n    .status()\n    .with_context(|| {\n      format!(\"Failed to run build command: {}\", build_cmd.join(\" \"))\n    })?;\n  if !status.success() {\n    deno_core::anyhow::bail!(\n      \"{} build failed (exit code: {})\",\n      detection.name,\n      status.code().unwrap_or(-1)\n    );\n  }\n  Ok(())\n}\n\n/// Detect a web framework in the given directory.\n///\n/// Detection priority:\n/// 1. Config-file based detection (highest priority)\n/// 2. Package.json dependency-based detection\n/// 3. deno.json import-based detection\npub fn detect_framework(\n  dir: &Path,\n) -> Result<Option<FrameworkDetection>, AnyError> {\n  // --- Config-file based detection (highest priority) ---","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/tools/framework.rs#L130-L166","documentation":"`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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\ndeno desktop          # Next.js build failed (exit code: 1)\n\n# after\nnpm run build         # shows the real error (e.g. type error in src/app/page.tsx)\n# fix the reported error, then:\ndeno desktop","handlingStrategy":"validation","validationCode":"# prove the framework build passes before invoking deno desktop:\nnpm install && npm run build   # or: npx vite build / npm run build\n# only then:\ndeno desktop","typeGuard":null,"tryCatchPattern":"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.","preventionTips":["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"],"tags":["build","framework","desktop","child-process","exit-code"],"backgroundTag":"child-process-build-failure","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}