{"record":{"id":"89d7d3a69ab4eafe","repo":"TencentCloud/TencentDB-Agent-Memory","slug":"missing-core-module-at-distpath-run-pnpm-buil","errorCode":null,"errorMessage":"Missing core module at ${distPath}. Run `pnpm build` or install the official package.","messagePattern":"Missing core module at (.+?)\\. Run `pnpm build` or install the official package\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"MemoryCore/src/utils/clean-context-runner.ts","lineNumber":142,"sourceCode":"  try { candidates.add(path.dirname(fileURLToPath(import.meta.url))); } catch { /* ignore */ }\n\n  for (const start of candidates) {\n    const found = findPackageRoot(start, \"openclaw\");\n    if (found) { _rootCache = found; return found; }\n  }\n  throw new Error(\"Unable to resolve OpenClaw root. Set OPENCLAW_ROOT or run `pnpm build`.\");\n}\n\nlet _loadPromise: Promise<RunEmbeddedPiAgentFn> | null = null;\n\nfunction loadRunEmbeddedPiAgent(logger?: RunnerLogger): Promise<RunEmbeddedPiAgentFn> {\n  if (_loadPromise) return _loadPromise;\n\n  _loadPromise = (async () => {\n    const t0 = Date.now();\n    const distPath = path.join(resolveOpenClawRoot(), \"dist\", \"extensionAPI.js\");\n    if (!fsSync.existsSync(distPath)) {\n      throw new Error(`Missing core module at ${distPath}. Run \\`pnpm build\\` or install the official package.`);\n    }\n    const mod = await import(pathToFileURL(distPath).href);\n    if (typeof mod.runEmbeddedPiAgent !== \"function\") {\n      throw new Error(\"runEmbeddedPiAgent not exported from dist/extensionAPI.js\");\n    }\n    logger?.info(`${TAG} loadRunEmbeddedPiAgent: dist/ import OK (${Date.now() - t0}ms)`);\n    return mod.runEmbeddedPiAgent as RunEmbeddedPiAgentFn;\n  })();\n\n  _loadPromise.catch(() => { _loadPromise = null; });\n  return _loadPromise;\n}\n\n/**\n * Pre-warm the embedded agent import. Call this during plugin init to avoid\n * the cold-start penalty on the first actual extraction run.\n * Returns immediately (fire-and-forget) — errors are swallowed.\n */","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/3efcd317b84146d6a08518ac0f7ee7c8a8d200ec/MemoryCore/src/utils/clean-context-runner.ts#L124-L160","documentation":"loadRunEmbeddedPiAgent dynamically imports <openclaw-root>/dist/extensionAPI.js. Before importing it checks fsSync.existsSync; if the built core module is absent it throws with the full path so the developer knows to rebuild the package or install the official one. This is a fail-fast guard against importing a nonexistent file.","triggerScenarios":"First call that resolves the embedded Pi agent (resolveRunEmbeddedPiAgent or prewarmEmbeddedAgent) when dist/extensionAPI.js does not exist — package never built, build output cleaned, or OPENCLAW_ROOT points at a source-only checkout.","commonSituations":"CI caching node_modules but not build artifacts; `pnpm clean` removing dist; installing a stripped/published package without dist; pointing OPENCLAW_ROOT at a repo clone that was never built.","solutions":["Run `pnpm build` in the openclaw package to generate dist/extensionAPI.js","Correct OPENCLAW_ROOT if it points to the wrong directory","Install the official package version that ships dist/extensionAPI.js","Ensure your build/CI pipeline persists the dist output between steps"],"exampleFix":"// before (CI)\n- run: pnpm install --prod\n// after\n- run: pnpm install && pnpm build\n- run: pnpm install --prod","handlingStrategy":"validation","validationCode":"const distPath = path.join(process.env.OPENCLAW_ROOT ?? 'node_modules/openclaw', 'dist', 'extensionAPI.js');\nif (!fsSync.existsSync(distPath)) throw new Error(`build artifact missing: ${distPath}`);","typeGuard":null,"tryCatchPattern":"try { const run = await loadRunEmbeddedPiAgent(logger); } catch (e) { if (/Missing core module/.test(e.message)) { logger.error('Run `pnpm build` in openclaw or install the official package'); } else throw e; }","preventionTips":["Include `pnpm build` in the image build step so dist/ ships with deployments","Assert dist/extensionAPI.js exists in a preflight/startup check","Don't clean dist between CI install and runtime stages"],"tags":["build","missing-file","dynamic-import"],"backgroundTag":"missing-build-artifact","analyzedSha":"3efcd317b84146d6a08518ac0f7ee7c8a8d200ec","analyzedAt":"2026-09-01T05:44:22.276Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}