paperclipai/paperclip · error

Package package.json not found at

Error message

Package package.json not found at ${packageJsonPath}

What it means

Precondition check in packLocalPackage: the helper was asked to pack a local workspace package (e.g. packages/shared) but no package.json exists at the resolved package path. This usually means the create-paperclip-plugin scaffolder ran from a repo checkout where the SDK's relative path to the monorepo package is wrong, or the package directory is missing/misnamed.

Solutions

  1. Run the command from the package directory (or pass the correct path) so package.json exists at the expected location.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/plugins/create-paperclip-plugin/src/index.ts:93 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at packages/plugins/create-paperclip-plugin/src/index.ts:93

}

function getRepoRootFromSdkPath(sdkPath: string): string {
  return path.resolve(sdkPath, "..", "..", "..");
}

function getLocalSharedPackagePath(sdkPath: string): string {
  return path.resolve(getRepoRootFromSdkPath(sdkPath), "packages", "shared");
}

function isInsideDir(targetPath: string, parentPath: string): boolean {
  const relative = path.relative(parentPath, targetPath);
  return relative === "" || (!relative.startsWith("..") && !path.isAbsolute(relative));
}

function packLocalPackage(packagePath: string, outputDir: string): string {
  const packageJsonPath = path.join(packagePath, "package.json");
  if (!fs.existsSync(packageJsonPath)) {
    throw new Error(`Package package.json not found at ${packageJsonPath}`);
  }

  const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8")) as {
    name?: string;
    version?: string;
  };
  const packageName = packageJson.name ?? path.basename(packagePath);
  const packageVersion = packageJson.version ?? "0.0.0";
  const tarballFileName = `${packageName.replace(/^@/, "").replace("/", "-")}-${packageVersion}.tgz`;
  const sdkBundleDir = path.join(outputDir, ".paperclip-sdk");

  fs.mkdirSync(sdkBundleDir, { recursive: true });
  execFileSync("pnpm", ["build"], { cwd: packagePath, stdio: "pipe" });
  execFileSync("pnpm", ["pack", "--pack-destination", sdkBundleDir], { cwd: packagePath, stdio: "pipe" });

  const tarballPath = path.join(sdkBundleDir, tarballFileName);
  if (!fs.existsSync(tarballPath)) {
    throw new Error(`Packed tarball was not created at ${tarballPath}`);

View on GitHub (pinned to a7e689b3c3)