can1357/oh-my-pi · error · Error
npm install failed with exit code ${result.exitCode}
Error message
npm install failed with exit code ${result.exitCode} What it means
Thrown when the self-update flow installs via npm (`npm install -g ...`) and the npm process exits non-zero. Like the bun variant, npm's diagnostic output is swallowed; only the exit code is reported. It indicates the target version could not be installed globally with npm.
Source
Thrown at packages/coding-agent/src/cli/update-cli.ts:1549
if (pruneResult && pruneResult.removedEntries > 0) {
console.log(chalk.dim(`Pruned ${pruneResult.removedEntries} stale Bun cache entries`));
}
} catch (err) {
console.log(chalk.yellow(`Warning: could not prune stale Bun cache entries: ${err}`));
}
return verification;
}
async function updateViaNpm(release: ReleaseInfo): Promise<InstalledVersionVerification | undefined> {
console.log(chalk.dim("Updating via npm..."));
if (release.packages.pkg !== PACKAGE) {
await migrateRenamedInstall(release, packageManagerMigrationSteps("npm", release));
return undefined;
}
const args = buildNpmInstallArgs(release.version, currentNativeTag(), release.packages);
const result = await $`npm ${args}`.nothrow();
if (result.exitCode !== 0) {
throw new Error(`npm install failed with exit code ${result.exitCode}`);
}
return await verifyInstalledVersion(release.version);
}
/** Injectable steps for {@link updateViaManager}; mirrors {@link RenameMigrationSteps}. */
export interface ManagerUpdateSteps {
/** Manager name used in progress and recovery messages. */
manager: string;
/**
* Run the manager's global install. Resolves to the PATH-resolved launcher
* check, or `undefined` when a rename migration already verified and
* reported its own result.
*/
install(): Promise<InstalledVersionVerification | undefined>;
/** Re-check the PATH-resolved launcher after the install threw. */
verify(): Promise<InstalledVersionVerification>;
/** Take `launcherPath` over with the standalone release binary. */
repair(launcherPath: string): Promise<void>;View on GitHub (pinned to 9690622007)
Solutions
- Run the equivalent `npm install -g <pkg>@<version>` manually to see npm's actual error
- Fix npm prefix permissions (use a user-owned prefix via nvm/volta, or `npm config set prefix`)
- Verify registry access and that the version exists (`npm view <pkg>@<version>`)
- Clear the npm cache (`npm cache clean --force`) if EINTEGRY/corruption errors appear
- Update via a different method (bun, brew, or the standalone binary installer)
Example fix
// before
const result = await $`npm ${args}`.nothrow();
if (result.exitCode !== 0) {
throw new Error(`npm install failed with exit code ${result.exitCode}`);
}
// after
const result = await $`npm ${args}`.nothrow();
if (result.exitCode !== 0) {
throw new Error(`npm install failed with exit code ${result.exitCode}: ${result.stderr.text()}`);
} Defensive patterns
Strategy: try-catch
Validate before calling
const probe = await $`npm ping`.nothrow();
if (probe.exitCode !== 0) throw new Error("npm registry unreachable; fix network before update"); Type guard
function npmInstallSucceeded(r: { exitCode: number }): r is { exitCode: 0 } {
return r.exitCode === 0;
} Try / catch
try {
await updateSelf();
} catch (err) {
if (err.message.startsWith("npm install failed")) {
// check npm prefix perms / registry, rerun `npm install -g <pkg>@<ver>` manually
} else throw err;
} Prevention
- Use a user-owned npm prefix (nvm/volta) to avoid EACCES on global installs
- Confirm the target version exists with `npm view <pkg>@<version>` before scripted updates
- Clear a suspect npm cache before release-train updates
When it happens
Trigger: Running self-update on an npm-managed install when `npm <install args>` fails — registry unreachable (EACCES on the global node_modules prefix, 404 for the version, network timeout, or npm not on PATH is caught earlier).
Common situations: npm global prefix requires sudo (common with system Node installs); corporate proxy/registry mirror missing the package version; npm cache corruption; disk full.
Related errors
- bun install failed with exit code ${result.exitCode}
- ${steps.manager} update did not produce a working launcher a
- brew update failed with exit code ${update.exitCode}
- brew ${args[0]} failed with exit code ${result.exitCode}
- mise upgrade failed with exit code ${result.exitCode}
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/6c4588e2e5967472.
Report an issue: GitHub.