{"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/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/create-astro/src/shell.ts#L56-L78","documentation":"Thrown by `create-astro`'s `shell()` helper when the spawned child process exits with a non-zero status code. The error message is the captured stderr if non-empty, otherwise the literal exit code. It indicates the underlying command ran to completion but reported failure.","triggerScenarios":"Any `shell()` invocation where the command exits non-zero: a package manager install failing on peer deps, a git command failing on auth, a build step failing. The check is `exitCode !== 0` after the process closes.","commonSituations":"`npm install` / `pnpm install` failing during scaffolding due to registry errors or peer-dep conflicts. A post-install script crashing. A git operation rejected by credentials. Network blips causing a package fetch failure mid-install.","solutions":["Read the captured stderr in the error message — it usually names the failing package or command.","Re-run the failing command manually outside create-astro to get full output and iterate.","Clear the package manager cache or switch registries if the failure is network/registry related.","Pin a known-good Node.js / package manager version if the failure is environment-specific."],"exampleFix":"# before — create-astro exits with 'Process exited with code 1'\nnpm create astro@latest\n\n# after — run install manually to see full error\ncd my-site && npm install 2>&1 | less","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await shell(cmd, flags);\n} catch (e) {\n  // e.message is stderr or 'Process exited with code N'\n  console.error('Command failed:', e.message);\n  throw e;\n}","preventionTips":["Always surface the captured stderr when re-throwing — it names the failing dependency.","Run the failing command manually outside the scaffolding flow to iterate quickly.","Pin Node/package-manager versions in CI to avoid environment-specific exit codes."],"tags":["create-astro","cli","process","exit-code"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}