{"record":{"id":"21cdcb6bfb792c55","repo":"can1357/oh-my-pi","slug":"unable-to-resolve-kokoro-package-in-runtime-at","errorCode":null,"errorMessage":"Unable to resolve ${KOKORO_PACKAGE} in runtime at ${nodeModules}","messagePattern":"Unable to resolve (.+?) in runtime at (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tts/tts-worker.ts","lineNumber":152,"sourceCode":"\treturn kokoroRuntime.load(async () => {\n\t\tconst runtimeDir = await ensureRuntimeInstalled({\n\t\t\truntimeDir: getTtsRuntimeDir(),\n\t\t\tinstall: {\n\t\t\t\tdependencies: { [KOKORO_PACKAGE]: KOKORO_VERSION },\n\t\t\t\toverrides: { [ONNXRUNTIME_NODE_PACKAGE]: ONNXRUNTIME_NODE_VERSION },\n\t\t\t\ttrustedDependencies: [ONNXRUNTIME_NODE_PACKAGE],\n\t\t\t},\n\t\t\tprobePackage: KOKORO_PACKAGE,\n\t\t\tonPhase: phase =>\n\t\t\t\ttransport.send({\n\t\t\t\t\ttype: \"progress\",\n\t\t\t\t\tid: requestId,\n\t\t\t\t\tevent: { modelKey, status: phase, name: `${KOKORO_PACKAGE}@${KOKORO_VERSION}` },\n\t\t\t\t}),\n\t\t});\n\t\tconst nodeModules = await installSharpStubResolver(runtimeDir);\n\t\tconst kokoroEntry = resolveRuntimeModule(nodeModules, KOKORO_PACKAGE);\n\t\tif (!kokoroEntry) throw new Error(`Unable to resolve ${KOKORO_PACKAGE} in runtime at ${nodeModules}`);\n\t\tconst transformersEntry = resolveRuntimeModule(nodeModules, TRANSFORMERS_PACKAGE);\n\t\tif (!transformersEntry) throw new Error(`Unable to resolve ${TRANSFORMERS_PACKAGE} in runtime at ${nodeModules}`);\n\t\tconst runtimeRequire = createRequire(kokoroEntry);\n\t\tconfigureTransformers(runtimeRequire(transformersEntry) as TransformersEnv);\n\t\treturn runtimeRequire(kokoroEntry) as KokoroRuntime;\n\t});\n}\n\nasync function loadModelOnDevice(\n\truntime: KokoroRuntime,\n\tspec: TtsLocalModelSpec,\n\tmodelKey: TtsLocalModelKey,\n\ttransport: TtsTransport,\n\trequestId: string,\n\tdevice: KokoroDevice,\n): Promise<KokoroTtsInstance> {\n\treturn runtime.KokoroTTS.from_pretrained(spec.repo, {\n\t\tdevice,","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tts/tts-worker.ts#L134-L170","documentation":"The TTS worker sets up an on-device Kokoro runtime inside a managed runtime directory: it installs a sharp stub resolver, then resolves the kokoro-js package entry from that runtime's node_modules. If resolveRuntimeModule cannot find KOKORO_PACKAGE there, loadKokoroRuntime throws, meaning the runtime installation did not produce a usable kokoro-js install.","triggerScenarios":"Loading local TTS when the runtime directory (runtimeDir) lacks node_modules containing kokoro-js — e.g. the runtime install step failed, was interrupted, or was skipped; a corrupted/partial install; a version bump changed the package layout so resolution fails.","commonSituations":"Offline or proxied environments where the runtime package download failed; disk-full or permission errors during runtime setup; a stale runtime dir from an older version; antivirus/cleanup tools deleting node_modules contents.","solutions":["Delete the TTS runtime directory and let the worker reinstall the runtime (re-triggers the kokoro-js install)","Check network/proxy access for the runtime install step and re-run; verify no install errors were swallowed","Verify the installed KOKORO_VERSION matches what the package expects (stale/partial install) and reinstall","Check disk space and write permissions on the runtime directory"],"exampleFix":"// before (stale runtime dir)\n// worker resolves kokoro-js from a broken node_modules and throws\n// after\n$`rm -rf ~/.omp/tts-runtime`; // then retry TTS so the runtime reinstalls cleanly","handlingStrategy":"retry","validationCode":"import { resolveRuntimeModule } from './runtime';\nconst nodeModules = await installSharpStubResolver(runtimeDir);\nif (!resolveRuntimeModule(nodeModules, KOKORO_PACKAGE)) await reinstallTtsRuntime(runtimeDir);","typeGuard":"function kokoroRuntimeReady(nodeModules) {\n  return resolveRuntimeModule(nodeModules, KOKORO_PACKAGE) !== undefined;\n}","tryCatchPattern":"try {\n  runtime = await loadKokoroRuntime();\n} catch (err) {\n  if (err.message.includes('Unable to resolve')) {\n    await resetTtsRuntimeDir(); // delete + reinstall\n    runtime = await loadKokoroRuntime();\n  } else throw err;\n}","preventionTips":["Verify network/proxy access before first-run runtime install","Monitor install logs for partial downloads; delete and reinstall on failure","Pin/verify runtime versions match the bundled KOKORO_VERSION after upgrades","Ensure adequate disk space and write permissions on the runtime directory"],"tags":["tts","module-resolution","runtime","installation","audio"],"backgroundTag":"module-not-found","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}