{"record":{"id":"82bb23dec957e0f7","repo":"earendil-works/pi","slug":"npm-args-join-exited-with-code-code","errorCode":null,"errorMessage":"npm ${args.join(\" \")} exited with code ${code ?? \"unknown\"}","messagePattern":"npm (.+?) exited with code (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/package-manager-cli.ts","lineNumber":102,"sourceCode":"\t\tthrow new Error(`Could not download managed installer ${label} from ${url}: HTTP ${response.status}`);\n\t}\n\treturn await response.text();\n}\n\nasync function runManagedNpmCi(stageDir: string): Promise<void> {\n\tconst args = [\n\t\t\"ci\",\n\t\t\"--ignore-scripts\",\n\t\t\"--min-release-age=0\",\n\t\t\"--omit=dev\",\n\t\t\"--include=optional\",\n\t\t\"--no-fund\",\n\t\t\"--no-audit\",\n\t\t\"--loglevel=error\",\n\t\t\"--progress=false\",\n\t];\n\tconst code = await waitForChildProcess(spawnProcess(\"npm\", args, { cwd: stageDir, stdio: \"inherit\" }));\n\tif (code !== 0) throw new Error(`npm ${args.join(\" \")} exited with code ${code ?? \"unknown\"}`);\n}\n\nfunction verifyManagedRelease(releaseDir: string, expectedVersion: string): void {\n\tconst binPath = join(\n\t\treleaseDir,\n\t\t\"node_modules\",\n\t\t\".bin\",\n\t\tprocess.platform === \"win32\" ? `${APP_NAME}.cmd` : APP_NAME,\n\t);\n\tconst result = spawnProcessSync(binPath, [\"--version\"], {\n\t\tencoding: \"utf8\",\n\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t});\n\tif (result.error || result.status !== 0) {\n\t\tconst reason = result.error?.message || result.stderr.trim() || `exit code ${result.status ?? \"unknown\"}`;\n\t\tthrow new Error(`Could not verify managed Pi ${expectedVersion}: ${reason}`);\n\t}\n\tconst installedVersion = result.stdout.trim();","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/coding-agent/src/package-manager-cli.ts#L84-L120","documentation":"Thrown by runManagedNpmCi when the spawned `npm ci` child process inside the staged release directory exits with a non-zero code (or the code is unknown). The full npm argument list is included; npm's own output went to the inherited stdio.","triggerScenarios":"Thrown at packages/coding-agent/src/package-manager-cli.ts:102 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Read the npm error output printed above this error to find the failing step","Check network access and npm registry reachability","Free up disk space or fix permissions in the staging directory if npm reports ENOSPC/EACCES","Retry the self-update; staging is cleaned between attempts"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4af9d21d3b4d664e4a29fcabfec85171077248e3","analyzedAt":"2026-08-24T13:07:14.692Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}