{"record":{"id":"a414a01d06bbcf05","repo":"can1357/oh-my-pi","slug":"unable-to-resolve-transformers-package-in-runti","errorCode":null,"errorMessage":"Unable to resolve ${TRANSFORMERS_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":154,"sourceCode":"\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,\n\t\tdtype: ttsDtypeOverride ?? spec.dtype,\n\t\tprogress_callback: info => sendProgress(transport, requestId, modelKey, info),","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tts/tts-worker.ts#L136-L172","documentation":"After resolving kokoro-js in the TTS runtime, loadKokoroRuntime also resolves @huggingface/transformers (TRANSFORMERS_PACKAGE), which kokoro-js needs for the ONNX inference pipeline. If the package is missing from the runtime's node_modules, the worker throws — the runtime install is incomplete even though kokoro-js itself resolved.","triggerScenarios":"Loading local TTS when the managed runtime directory contains kokoro-js but not @huggingface/transformers — partial/failed install, interrupted dependency fetch, or a version/packaging change that dropped the transitive dependency.","commonSituations":"Interrupted first-run install (network drop mid-download); manual deletion or cleanup of node_modules; dependency version drift where transformers is no longer installed alongside kokoro; permissions or disk-space failures during setup.","solutions":["Remove the runtime directory and retry so the full dependency set (kokoro-js + transformers) is reinstalled","Verify the runtime install logs for the failed transformers download and fix network/proxy access","Ensure the installed versions match the bundled KOKORO_VERSION expectations; reinstall on version mismatch","Check disk space and permissions on the runtime directory"],"exampleFix":"// before (partial runtime install)\n// kokoro-js present, @huggingface/transformers missing -> throws\n// after\n$`rm -rf ~/.omp/tts-runtime`; // retry TTS; worker reinstalls both packages","handlingStrategy":"retry","validationCode":"const nodeModules = await installSharpStubResolver(runtimeDir);\nif (!resolveRuntimeModule(nodeModules, TRANSFORMERS_PACKAGE)) await reinstallTtsRuntime(runtimeDir);","typeGuard":"function transformersRuntimeReady(nodeModules) {\n  return resolveRuntimeModule(nodeModules, TRANSFORMERS_PACKAGE) !== undefined;\n}","tryCatchPattern":"try {\n  runtime = await loadKokoroRuntime();\n} catch (err) {\n  if (err.message.includes(TRANSFORMERS_PACKAGE)) {\n    await resetTtsRuntimeDir(); // delete + reinstall full dependency set\n    runtime = await loadKokoroRuntime();\n  } else throw err;\n}","preventionTips":["Treat kokoro-js resolution success as insufficient — check transformers too before use","Guard first-run installs against network interruptions; retry full reinstalls","Keep the runtime directory versioned with the app so stale installs are bypassed","Check disk space and permissions when setup repeatedly fails midway"],"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"}