{"record":{"id":"5255a96ed8c88923","repo":"can1357/oh-my-pi","slug":"unable-to-resolve-sherpa-package-in-compiled-ru","errorCode":null,"errorMessage":"Unable to resolve ${SHERPA_PACKAGE} 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/stt/asr-worker.ts","lineNumber":164,"sourceCode":" * Memoized so the runtime loads once per process.\n */\nfunction loadSherpaRuntime(transport: SttTransport, requestId: string, modelKey: SttModelKey): Promise<SherpaRuntime> {\n\treturn sherpaRuntime.load(async () => {\n\t\tif (!isCompiledBinary()) return loadSourceSherpaRuntime(import.meta.url);\n\t\tconst runtimeDir = await ensureRuntimeInstalled({\n\t\t\truntimeDir: getSherpaRuntimeDir(),\n\t\t\tinstall: { dependencies: { [SHERPA_PACKAGE]: getSherpaVersionSpec() } },\n\t\t\tprobePackage: SHERPA_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: `${SHERPA_PACKAGE}@${getSherpaVersionSpec()}` },\n\t\t\t\t}),\n\t\t});\n\t\tconst nodeModules = path.join(runtimeDir, \"node_modules\");\n\t\tconst entry = resolveRuntimeModule(nodeModules, SHERPA_PACKAGE);\n\t\tif (!entry) throw new Error(`Unable to resolve ${SHERPA_PACKAGE} in compiled runtime at ${nodeModules}`);\n\t\treturn createRequire(entry)(entry) as SherpaRuntime;\n\t});\n}\n\nasync function loadPipelineOnDevice(\n\ttransformers: TransformersRuntime,\n\tspec: TransformersSttModelSpec,\n\tmodelKey: SttModelKey,\n\ttransport: SttTransport,\n\trequestId: string,\n\tdevice: TinyModelDevice,\n): Promise<AutomaticSpeechRecognitionPipeline> {\n\treturn transformers.pipeline(ASR_TASK, spec.repo, {\n\t\tdevice,\n\t\tdtype: sttModelDtypeOverride ?? spec.dtype,\n\t\tprogress_callback: info => sendProgress(transport, requestId, modelKey, info),\n\t});\n}","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/stt/asr-worker.ts#L146-L182","documentation":"In a compiled binary, the native sherpa-onnx addon is installed into a side runtime directory (node_modules under the STT runtime dir) and resolved via resolveRuntimeModule before being loaded with createRequire. If, after the ensureRuntimeInstalled step, the package entry still cannot be found at that node_modules path, the worker throws — the runtime install did not produce a loadable package.","triggerScenarios":"Loading any sherpa STT model in a compiled binary when resolveRuntimeModule(runtimeDir/node_modules, \"sherpa-onnx-node\") returns null — install failed silently, was interrupted, or the runtime dir is corrupt/partial.","commonSituations":"Disk-full or permission errors during the side runtime install, an interrupted first run leaving a partial runtime dir, antivirus quarantining native .node binaries, or a version-spec/install mismatch pointing at an incomplete tree.","solutions":["Delete the stale STT runtime directory under the tiny-models cache (…/stt-runtime/sherpa-*) and retry so ensureRuntimeInstalled reinstalls cleanly.","Check disk space and directory permissions for the cache dir.","Ensure your antivirus/security software is not removing .node native modules.","If it persists, verify the installed sherpa-onnx version actually ships a resolvable entry for your platform."],"exampleFix":"// before\nrm -rf ~/.cache/omp/tiny-models/stt-runtime/sherpa-*   # then retry the model load\n// after\nensureRuntimeInstalled(...) succeeds and resolveRuntimeModule finds the entry","handlingStrategy":"try-catch","validationCode":"const entry = resolveRuntimeModule(path.join(runtimeDir, \"node_modules\"), \"sherpa-onnx-node\");\nif (!entry) await ensureRuntimeInstalled({ runtimeDir, install: { dependencies: { \"sherpa-onnx-node\": spec } }, probePackage: \"sherpa-onnx-node\" });","typeGuard":null,"tryCatchPattern":"try { const runtime = await loadSherpaRuntime(transport, id, modelKey); } catch (err) { await rm(runtimeDir, { recursive: true, force: true }); /* retry once to reinstall the side runtime */ }","preventionTips":["On failure, wipe the versioned stt-runtime dir and reinstall rather than retrying against a corrupt tree.","Monitor disk space and permissions on the shared cache directory.","Exclude native .node files from antivirus scanning on end-user machines."],"tags":["native-module","runtime-install","stt"],"backgroundTag":"native-module-resolution-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}