can1357/oh-my-pi · error · Error

Unable to resolve ${packageName} in compiled runtime at ${no

Error message

Unable to resolve ${packageName} in compiled runtime at ${nodeModules}

What it means

prepareCompiledRuntime stubs `sharp`, patches the module resolver to the side runtime's node_modules, and then resolves the requested package's entrypoint (e.g. @huggingface/transformers). If the package cannot be resolved in the freshly installed compiled runtime, this error is thrown.

Source

Thrown at packages/coding-agent/src/subprocess/worker-runtime.ts:263

	const missing = await missingOnnxRuntimeCudaProviderFiles(binDir);
	if (missing.length === 0) return;

	await installOnnxRuntimeCudaProviders(packageDir, runtimeDir, binDir);
	const stillMissing = await missingOnnxRuntimeCudaProviderFiles(binDir);
	if (stillMissing.length === 0) return;
	throw new Error(
		`ONNX Runtime CUDA provider install completed but ${stillMissing.join(", ")} are still missing from ${binDir}. Remove the tiny-model side runtime cache at ${runtimeDir} and retry.`,
	);
}

/**
 * Prepare a freshly-installed compiled runtime for loading and return the
 * absolute entrypoint of `packageName` to `require`.
 */
async function prepareCompiledRuntime(runtimeDir: string, packageName: string): Promise<string> {
	const nodeModules = await installSharpStubResolver(runtimeDir);
	const entry = resolveRuntimeModule(nodeModules, packageName);
	if (!entry) throw new Error(`Unable to resolve ${packageName} in compiled runtime at ${nodeModules}`);
	return entry;
}

// ── Transformers version resolution ─────────────────────────────────

function resolveTransformersVersionSpec(): string {
	const manifest = packageJson as {
		optionalDependencies?: Record<string, string>;
		dependencies?: Record<string, string>;
	};
	const versionSpec =
		manifest.optionalDependencies?.[TRANSFORMERS_PACKAGE] ?? manifest.dependencies?.[TRANSFORMERS_PACKAGE];
	if (!versionSpec) throw new Error(`${TRANSFORMERS_PACKAGE} is missing from package.json optionalDependencies`);
	if (!versionSpec.startsWith("catalog:")) return versionSpec;
	if (COMPILED_TRANSFORMERS_VERSION) return COMPILED_TRANSFORMERS_VERSION;
	const installed = sourceRequire(`${TRANSFORMERS_PACKAGE}/package.json`) as { version: string };
	return installed.version;
}

View on GitHub (pinned to 9690622007)

Solutions

  1. Delete the side runtime cache directory (runtimeDir) and relaunch to trigger a clean reinstall.
  2. Re-run the runtime install with network access and optional dependencies enabled.
  3. If a version bump renamed the package, clear the old cache rather than reusing it.
  4. Check install logs from the initial side-runtime setup for the skipped/failed package.
Defensive patterns

Strategy: validation

Validate before calling

import { existsSync } from "node:fs";
function sideRuntimeHas(runtimeDir: string, pkg: string): boolean {
  return existsSync(path.join(runtimeDir, "node_modules", pkg, "package.json"));
}
if (!sideRuntimeHas(runtimeDir, "@huggingface/transformers")) {
  await reinstallSideRuntime(runtimeDir); // clean install before loading
}

Try / catch

try {
  const entry = await prepareCompiledRuntime(runtimeDir, TRANSFORMERS_PACKAGE);
} catch (err) {
  if (String(err.message).startsWith("Unable to resolve")) {
    await fs.rm(runtimeDir, { recursive: true, force: true });
    // reinstall then retry once
  } else throw err;
}

Prevention

When it happens

Trigger: Called from the compiled-runtime entry path after installSharpStubResolver(runtimeDir); resolveRuntimeModule(nodeModules, packageName) returns null because the requested package was not installed into the side runtime cache.

Common situations: Interrupted or failed side-runtime installation (network drop mid-install), optional dependency skipped, cache manually pruned, or a package rename between app versions leaving a stale cache without the new package name.

Related errors


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