TencentCloud/TencentDB-Agent-Memory · error

Missing core module at ${distPath}. Run `pnpm build` or inst

Error message

Missing core module at ${distPath}. Run `pnpm build` or install the official package.

What it means

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.

Source

Thrown at MemoryCore/src/utils/clean-context-runner.ts:142

  try { candidates.add(path.dirname(fileURLToPath(import.meta.url))); } catch { /* ignore */ }

  for (const start of candidates) {
    const found = findPackageRoot(start, "openclaw");
    if (found) { _rootCache = found; return found; }
  }
  throw new Error("Unable to resolve OpenClaw root. Set OPENCLAW_ROOT or run `pnpm build`.");
}

let _loadPromise: Promise<RunEmbeddedPiAgentFn> | null = null;

function loadRunEmbeddedPiAgent(logger?: RunnerLogger): Promise<RunEmbeddedPiAgentFn> {
  if (_loadPromise) return _loadPromise;

  _loadPromise = (async () => {
    const t0 = Date.now();
    const distPath = path.join(resolveOpenClawRoot(), "dist", "extensionAPI.js");
    if (!fsSync.existsSync(distPath)) {
      throw new Error(`Missing core module at ${distPath}. Run \`pnpm build\` or install the official package.`);
    }
    const mod = await import(pathToFileURL(distPath).href);
    if (typeof mod.runEmbeddedPiAgent !== "function") {
      throw new Error("runEmbeddedPiAgent not exported from dist/extensionAPI.js");
    }
    logger?.info(`${TAG} loadRunEmbeddedPiAgent: dist/ import OK (${Date.now() - t0}ms)`);
    return mod.runEmbeddedPiAgent as RunEmbeddedPiAgentFn;
  })();

  _loadPromise.catch(() => { _loadPromise = null; });
  return _loadPromise;
}

/**
 * Pre-warm the embedded agent import. Call this during plugin init to avoid
 * the cold-start penalty on the first actual extraction run.
 * Returns immediately (fire-and-forget) — errors are swallowed.
 */

View on GitHub (pinned to 3efcd317b8)

Solutions

  1. Run `pnpm build` in the openclaw package to generate dist/extensionAPI.js
  2. Correct OPENCLAW_ROOT if it points to the wrong directory
  3. Install the official package version that ships dist/extensionAPI.js
  4. Ensure your build/CI pipeline persists the dist output between steps

Example fix

// before (CI)
- run: pnpm install --prod
// after
- run: pnpm install && pnpm build
- run: pnpm install --prod
Defensive patterns

Strategy: validation

Validate before calling

const distPath = path.join(process.env.OPENCLAW_ROOT ?? 'node_modules/openclaw', 'dist', 'extensionAPI.js');
if (!fsSync.existsSync(distPath)) throw new Error(`build artifact missing: ${distPath}`);

Try / catch

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; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of TencentCloud/TencentDB-Agent-Memory@3efcd317b8 (2026-09-01). Data as JSON: /api/errors/89d7d3a69ab4eafe. Report an issue: GitHub.