earendil-works/pi · error · Error

npm exited with code

Error message

npm ${args.join(" ")} exited with code ${code ?? "unknown"}

What it means

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.

Solutions

  1. Read the npm error output printed above this error to find the failing step
  2. Check network access and npm registry reachability
  3. Free up disk space or fix permissions in the staging directory if npm reports ENOSPC/EACCES
  4. Retry the self-update; staging is cleaned between attempts
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at packages/coding-agent/src/package-manager-cli.ts:102 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24). Data as JSON: /api/errors/82bb23dec957e0f7. Report an issue: GitHub.

Appendix: source

Thrown at packages/coding-agent/src/package-manager-cli.ts:102

		throw new Error(`Could not download managed installer ${label} from ${url}: HTTP ${response.status}`);
	}
	return await response.text();
}

async function runManagedNpmCi(stageDir: string): Promise<void> {
	const args = [
		"ci",
		"--ignore-scripts",
		"--min-release-age=0",
		"--omit=dev",
		"--include=optional",
		"--no-fund",
		"--no-audit",
		"--loglevel=error",
		"--progress=false",
	];
	const code = await waitForChildProcess(spawnProcess("npm", args, { cwd: stageDir, stdio: "inherit" }));
	if (code !== 0) throw new Error(`npm ${args.join(" ")} exited with code ${code ?? "unknown"}`);
}

function verifyManagedRelease(releaseDir: string, expectedVersion: string): void {
	const binPath = join(
		releaseDir,
		"node_modules",
		".bin",
		process.platform === "win32" ? `${APP_NAME}.cmd` : APP_NAME,
	);
	const result = spawnProcessSync(binPath, ["--version"], {
		encoding: "utf8",
		stdio: ["ignore", "pipe", "pipe"],
	});
	if (result.error || result.status !== 0) {
		const reason = result.error?.message || result.stderr.trim() || `exit code ${result.status ?? "unknown"}`;
		throw new Error(`Could not verify managed Pi ${expectedVersion}: ${reason}`);
	}
	const installedVersion = result.stdout.trim();

View on GitHub (pinned to 4af9d21d3b)