paperclipai/paperclip · error · Error

Failed to prepare workspace build artifacts before starting…

Error message

Failed to prepare workspace build artifacts before starting the Paperclip dev server.
${formatError(result.error)}

What it means

ensureDevWorkspaceBuildDeps spawnSync'd the build-prep script and it failed to spawn at all (error set); the original spawn error is wrapped with context about the dev-server preparation step.

Solutions

  1. Read the underlying build error in the output, fix the workspace build, and retry.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at cli/src/commands/run.ts:173 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of paperclipai/paperclip@01ad858492 (2026-08-18). Data as JSON: /api/errors/45f2a3c8fd65f74e. Report an issue: GitHub.

Appendix: source

Thrown at cli/src/commands/run.ts:199

function getMissingModuleSpecifier(err: unknown): string | null {
  if (!(err instanceof Error)) return null;
  const packageMatch = err.message.match(/Cannot find package '([^']+)' imported from/);
  if (packageMatch?.[1]) return packageMatch[1];
  const moduleMatch = err.message.match(/Cannot find module '([^']+)'/);
  if (moduleMatch?.[1]) return moduleMatch[1];
  return null;
}

function maybeEnableUiDevMiddleware(entrypoint: string): void {
  if (process.env.PAPERCLIP_UI_DEV_MIDDLEWARE !== undefined) return;
  const normalized = entrypoint.replaceAll("\\", "/");
  if (normalized.endsWith("/server/src/index.ts") || normalized.endsWith("@paperclipai/server/src/index.ts")) {
    process.env.PAPERCLIP_UI_DEV_MIDDLEWARE = "true";
  }
}

function ensureDevWorkspaceBuildDeps(projectRoot: string): void {
  const buildScript = path.resolve(projectRoot, "scripts/ensure-plugin-build-deps.mjs");
  if (!fs.existsSync(buildScript)) return;

  const result = spawnSync(process.execPath, [buildScript], {
    cwd: projectRoot,
    stdio: "inherit",
    timeout: 120_000,
  });

  if (result.error) {
    throw new Error(
      `Failed to prepare workspace build artifacts before starting the Paperclip dev server.\n${formatError(result.error)}`,
    );
  }

  if ((result.status ?? 1) !== 0) {
    throw new Error(
      "Failed to prepare workspace build artifacts before starting the Paperclip dev server.",

View on GitHub (pinned to 01ad858492)