paperclipai/paperclip · critical · Error
Package package.json not found at ${packageJsonPath}
Error message
Package package.json not found at ${packageJsonPath} What it means
packLocalPackage expects a real package directory containing package.json; it existsSync-checks the path and throws if absent before attempting to read name/version. This runs during plugin scaffolding when bundling a local shared package (e.g. @paperclip/shared) for the SDK harness.
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 67001ec6eb)
Solutions
- Run create-paperclip-plugin from within the Paperclip monorepo root so getRepoRootFromSdkPath resolves correctly.
- If passing --sdk-path, point it at the packages/shared directory that contains package.json.
- Verify packages/shared/package.json exists in your checkout (git status / missing submodule).
Example fix
// before: run from a directory whose packages/shared has no package.json $ cd /tmp && create-paperclip-plugin ... // after $ cd /path/to/paperclip-monorepo && create-paperclip-plugin ...
Defensive patterns
Strategy: validation
Validate before calling
import fs from 'node:fs';
import path from 'node:path';
function ensurePackageJson(pkgDir: string): void {
if (!fs.existsSync(path.join(pkgDir, 'package.json'))) {
throw new Error(`Cannot scaffold: missing ${path.join(pkgDir, 'package.json')}`);
}
} Prevention
- Run the scaffolder from the Paperclip monorepo root.
- If passing --sdk-path, point it at packages/shared (which contains package.json).
- Confirm the checkout includes the packages directory.
When it happens
Trigger: getLocalSharedPackagePath resolved a directory that does not contain package.json — e.g. the create-paperclip-plugin tool is being run from outside the Paperclip monorepo, the repo layout changed, or the SDK path argument points at the wrong location.
Common situations: Running the scaffolder against a fork where packages/shared was renamed/moved; invoking from a shallow checkout missing that directory; wrong --sdk-path argument.
Related errors
- Packed tarball was not created at ${tarballPath}
- Invalid template '${template}'. Expected one of: ${VALID_TEM
- Invalid plugin name. Must be lowercase and may include scope
- Could not locate local Paperclip skills directory. Expected
- Export output path ${root} exists and is not a directory.
AI-assisted analysis of paperclipai/paperclip@67001ec6eb (2026-08-12).
Data as JSON: /api/errors/f8935e82acf5da76.
Report an issue: GitHub.