{"record":{"id":"97fc78b0c6889a49","repo":"withastro/astro","slug":"process-exited-with-code-exitcode","errorCode":null,"errorMessage":"Process exited with code ${exitCode}","messagePattern":"Process exited with code (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/create-astro/src/shell.ts","lineNumber":74,"sourceCode":"\t\t\tcwd: opts.cwd,\n\t\t\tstdio: opts.stdio,\n\t\t\ttimeout: opts.timeout,\n\t\t});\n\t\tconst done = new Promise<void>((resolve, reject) => {\n\t\t\tchild.once('error', reject);\n\t\t\tchild.once('close', () => resolve());\n\t\t});\n\t\t[stdout, stderr] = await Promise.all([text(child.stdout), text(child.stderr), done]);\n\t} catch (e) {\n\t\tconst message = e instanceof Error ? e.message : stderr || 'Unknown error';\n\t\tthrow new Error(message);\n\t}\n\tconst { exitCode } = child;\n\tif (exitCode === null) {\n\t\tthrow new Error('Timeout');\n\t}\n\tif (exitCode !== 0) {\n\t\tthrow new Error(stderr || `Process exited with code ${exitCode}`);\n\t}\n\treturn { stdout, stderr, exitCode };\n}\n","sourceCodeStart":56,"sourceCodeEnd":78,"githubUrl":"https://github.com/withastro/astro/blob/52e6c34790cc8ac4e69e6135ace06049867e5c4a/packages/create-astro/src/shell.ts#L56-L78","documentation":"create-astro ships a minimal execa-like helper (packages/create-astro/src/shell.ts) that spawns external commands (npm/pnpm/yarn/bun install, git init, etc.) while scaffolding a project. After the child process closes, any non-zero exit code is fatal; when stderr is empty the helper falls back to this generic 'Process exited with code N' message. So the error means a subprocess failed without emitting any diagnostic output on stderr.","triggerScenarios":"Running `npm create astro@latest` (or invoking create-astro programmatically) where a spawned step fails silently: package-manager install exiting non-zero with empty stderr, `git init`/`git clone` failing because git is not installed, or a command being killed by a signal/timeout path that leaves exitCode set and stderr blank.","commonSituations":"Broken registry/proxy or corporate network blocking npm during dependency install; git missing from PATH when a template initializes a repo; disk-full or antivirus interference on Windows; flaky CI networks where the package manager dies without printing anything.","solutions":["Re-run the create command and watch the terminal for which step failed (install vs git vs template fetch).","cd into the generated directory and run the same package-manager install manually (e.g. `npm install`) to get the real error output.","Verify required binaries exist: `git --version` and your package manager `--version` are on PATH.","Check registry connectivity/proxy config (npm config get registry, proxy env vars) if the failing step is dependency installation.","Free disk space / disable antivirus scans for the project folder if installs die silently on Windows."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Before invoking create-astro programmatically, verify the binaries it shells out to exist:\nimport { which } from 'shelljs'; // or: spawnSync('git', ['--version'])\nfor (const bin of ['git', 'npm']) {\n  if (!which(bin)) console.warn(`${bin} not found on PATH — scaffolding steps may fail`);\n}","typeGuard":null,"tryCatchPattern":"import { shell } from 'create-astro/shell'; // internal usage\ntry {\n  await shell('npm', ['install'], { cwd: projectDir, timeout: 120_000 });\n} catch (e) {\n  // message is either stderr or 'Process exited with code N' — surface both to the user\n  throw new Error(`Dependency installation failed: ${e instanceof Error ? e.message : e}`);\n}","preventionTips":["Pre-install and verify git plus your package manager on PATH before scaffolding.","Run create-astro in an environment with registry access (check proxy/VPN).","Pass a generous timeout when invoking shell programmatically so slow installs exit as 'Timeout' rather than dying silently."],"tags":["create-astro","subprocess","cli","scaffolding","install"],"backgroundTag":"subprocess-non-zero-exit","analyzedSha":"52e6c34790cc8ac4e69e6135ace06049867e5c4a","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}