can1357/oh-my-pi · error · Error

Package installed but package.json not found at ${pkgPath}

Error message

Package installed but package.json not found at ${pkgPath}

What it means

installPlugin runs `bun install <pkg>` into the plugins directory, then reads the installed package's package.json to return plugin metadata (name, version, etc.). This error is thrown when bun install reported success (exit code 0) but the expected package.json at PLUGINS_DIR/node_modules/<name>/package.json does not exist. It signals an inconsistency between what bun claimed to install and what is actually on disk.

Source

Thrown at packages/coding-agent/src/extensibility/plugins/installer.ts:74

	// Drain both pipes concurrently with proc.exited to avoid a pipe-buffer
	// deadlock if bun install floods stdout/stderr.
	const [exitCode, , stderr] = await Promise.all([
		proc.exited,
		new Response(proc.stdout).text(),
		new Response(proc.stderr).text(),
	]);
	if (exitCode !== 0) {
		throw new Error(`Failed to install ${packageName}: ${stderr}`);
	}

	// Extract the actual package name (without version specifier) for path lookup
	const actualName = extractPackageName(packageName);

	// Read the installed package's package.json
	const pkgPath = path.join(PLUGINS_DIR, "node_modules", actualName, "package.json");
	const pkgFile = Bun.file(pkgPath);
	if (!(await pkgFile.exists())) {
		throw new Error(`Package installed but package.json not found at ${pkgPath}`);
	}

	const pkg = await pkgFile.json();

	return {
		name: pkg.name,
		version: pkg.version,
		path: path.join(PLUGINS_DIR, "node_modules", actualName),
		manifest: pkg.omp || pkg.pi || { version: pkg.version },
		enabledFeatures: null,
		enabled: true,
	};
}

export async function uninstallPlugin(name: string): Promise<void> {
	// Validate package name
	validatePackageName(name);

View on GitHub (pinned to 9690622007)

Solutions

  1. Re-run the install (delete ~/.omp/plugins and reinstall) to rule out a stale/partial install
  2. Verify the package name/spec is a plain npm name with optional semver, not an alias, git URL, or file path
  3. Check that ~/.omp/plugins/node_modules/<extracted-name>/package.json exists manually to see what bun actually wrote
  4. Update the CLI — extractPackageName may have a parsing bug for your spec format

Example fix

// before: alias/remote spec confuses path lookup
await installPlugin("my-plugin@npm:other-plugin@1.2.3");
// after: install the real package name
await installPlugin("other-plugin@1.2.3");
Defensive patterns

Strategy: validation

Validate before calling

import path from "node:path";
const pkgPath = path.join(agentDir, "plugins", "node_modules", extractPackageName(spec), "package.json");
if (!(await Bun.file(pkgPath).exists())) {
	throw new Error(`install target missing before/after install: ${pkgPath}`);
}

Type guard

function isRecordWithPackageMeta(v: unknown): v is { name: string; version?: string } {
	return typeof v === "object" && v !== null && "name" in v && typeof (v as { name: unknown }).name === "string";
}

Try / catch

try {
	const plugin = await installPlugin(spec);
} catch (err) {
	if (err instanceof Error && err.message.includes("package.json not found")) {
		// retry once after clearing partial install, or surface install-layout error
	}
	throw err;
}

Prevention

When it happens

Trigger: installPlugin(packageName) completes bun install with exit code 0, but extractPackageName(packageName) yields a directory name that does not match where bun actually placed the package — e.g. the version specifier parses to a different name than installed, the package was deduped/hoisted, or the install was partially cleaned up before the exists() check.

Common situations: Installing a package whose name contains a version/tag that extractPackageName mishandles; a race where another process removes node_modules content; an aliased install spec (npm alias like `foo@npm:bar`) where the on-disk folder differs from the requested name; corrupted or interrupted install cache.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/745db6ec04685d71. Report an issue: GitHub.