{"record":{"id":"d3903654999fd34e","repo":"can1357/oh-my-pi","slug":"unable-to-resolve-packagename-in-compiled-runti","errorCode":null,"errorMessage":"Unable to resolve ${packageName} in compiled runtime at ${nodeModules}","messagePattern":"Unable to resolve (.+?) in compiled runtime at (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/subprocess/worker-runtime.ts","lineNumber":263,"sourceCode":"\tconst missing = await missingOnnxRuntimeCudaProviderFiles(binDir);\n\tif (missing.length === 0) return;\n\n\tawait installOnnxRuntimeCudaProviders(packageDir, runtimeDir, binDir);\n\tconst stillMissing = await missingOnnxRuntimeCudaProviderFiles(binDir);\n\tif (stillMissing.length === 0) return;\n\tthrow new Error(\n\t\t`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.`,\n\t);\n}\n\n/**\n * Prepare a freshly-installed compiled runtime for loading and return the\n * absolute entrypoint of `packageName` to `require`.\n */\nasync function prepareCompiledRuntime(runtimeDir: string, packageName: string): Promise<string> {\n\tconst nodeModules = await installSharpStubResolver(runtimeDir);\n\tconst entry = resolveRuntimeModule(nodeModules, packageName);\n\tif (!entry) throw new Error(`Unable to resolve ${packageName} in compiled runtime at ${nodeModules}`);\n\treturn entry;\n}\n\n// ── Transformers version resolution ─────────────────────────────────\n\nfunction resolveTransformersVersionSpec(): string {\n\tconst manifest = packageJson as {\n\t\toptionalDependencies?: Record<string, string>;\n\t\tdependencies?: Record<string, string>;\n\t};\n\tconst versionSpec =\n\t\tmanifest.optionalDependencies?.[TRANSFORMERS_PACKAGE] ?? manifest.dependencies?.[TRANSFORMERS_PACKAGE];\n\tif (!versionSpec) throw new Error(`${TRANSFORMERS_PACKAGE} is missing from package.json optionalDependencies`);\n\tif (!versionSpec.startsWith(\"catalog:\")) return versionSpec;\n\tif (COMPILED_TRANSFORMERS_VERSION) return COMPILED_TRANSFORMERS_VERSION;\n\tconst installed = sourceRequire(`${TRANSFORMERS_PACKAGE}/package.json`) as { version: string };\n\treturn installed.version;\n}","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/subprocess/worker-runtime.ts#L245-L281","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Delete the side runtime cache directory (runtimeDir) and relaunch to trigger a clean reinstall.","Re-run the runtime install with network access and optional dependencies enabled.","If a version bump renamed the package, clear the old cache rather than reusing it.","Check install logs from the initial side-runtime setup for the skipped/failed package."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import { existsSync } from \"node:fs\";\nfunction sideRuntimeHas(runtimeDir: string, pkg: string): boolean {\n  return existsSync(path.join(runtimeDir, \"node_modules\", pkg, \"package.json\"));\n}\nif (!sideRuntimeHas(runtimeDir, \"@huggingface/transformers\")) {\n  await reinstallSideRuntime(runtimeDir); // clean install before loading\n}","typeGuard":null,"tryCatchPattern":"try {\n  const entry = await prepareCompiledRuntime(runtimeDir, TRANSFORMERS_PACKAGE);\n} catch (err) {\n  if (String(err.message).startsWith(\"Unable to resolve\")) {\n    await fs.rm(runtimeDir, { recursive: true, force: true });\n    // reinstall then retry once\n  } else throw err;\n}","preventionTips":["Let the runtime install finish fully; avoid killing the process mid-install.","Clear stale caches after app version upgrades that change dependency names.","Verify optional dependencies are installed in your deployment method (tarball/binary)."],"tags":["module-resolution","side-runtime","install"],"backgroundTag":"module-not-found","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}