prisma/prisma · error · Error
Could not find monorepo root (pnpm-workspace.yaml)
Error message
Could not find monorepo root (pnpm-workspace.yaml)
What it means
Thrown by findMonorepoRoot in the CLI's record.ts script when walking up from the start directory to '/' without finding a pnpm-workspace.yaml file. The recording script depends on being run inside the Prisma Next monorepo (it resolves workspace paths relative to the root).
Source
Thrown at packages/1-framework/3-tooling/cli/scripts/record.ts:136
return execFileSync(process.execPath, [CLI_BIN, ...args.split(/\s+/).filter(Boolean)], {
cwd,
encoding: 'utf-8',
env: { ...process.env, NO_COLOR: '1', CI: 'true' },
stdio: ['pipe', 'pipe', 'pipe'],
});
} catch (error: unknown) {
const e = error as { stdout?: string; stderr?: string };
return `${e.stdout ?? ''}${e.stderr ?? ''}`;
}
}
function findMonorepoRoot(startDir: string): string {
let dir = startDir;
while (dir !== '/') {
if (existsSync(join(dir, 'pnpm-workspace.yaml'))) return dir;
dir = dirname(dir);
}
throw new Error('Could not find monorepo root (pnpm-workspace.yaml)');
}
const MONOREPO_ROOT = findMonorepoRoot(CLI_ROOT);
/**
* Workspace is created inside the test fixture app so jiti can resolve
* workspace packages (adapter-postgres, driver-postgres, etc.) when
* loading prisma-next.config.ts.
*/
const FIXTURE_APP_DIR = join(MONOREPO_ROOT, 'test/integration/test/fixtures/cli/cli-e2e-test-app');
// --- Test utils (loaded dynamically to avoid adding deps to CLI package) ---
interface DbClient {
query(sql: string): Promise<unknown>;
}
interface TestUtils {View on GitHub (pinned to a20d61fb6f)
Solutions
- Run the script from inside the Prisma Next monorepo (e.g. packages/1-framework/3-tooling/cli).
- Ensure pnpm-workspace.yaml exists at the repository root.
- If invoking programmatically, confirm the __dirname resolution points inside the repo.
Example fix
// before: run from /tmp cd /tmp && tsx /path/to/record.ts // throws // after: run from the cli package inside the monorepo pnpm --filter @prisma/cli exec tsx scripts/record.ts
Defensive patterns
Strategy: validation
Validate before calling
import { existsSync } from 'node:fs';
import { dirname, join } from 'node:path';
function hasMonorepoRoot(start: string): boolean {
let dir = start;
while (dir !== '/') {
if (existsSync(join(dir, 'pnpm-workspace.yaml'))) return true;
dir = dirname(dir);
}
return false;
} Prevention
- Always run record.ts from within the Prisma Next monorepo.
- Keep pnpm-workspace.yaml at the repository root.
When it happens
Trigger: Running `tsx scripts/record.ts` (or `npx tsx scripts/record.ts`) from a directory that is not inside the Prisma Next monorepo — e.g. the file was copied elsewhere, or invoked from /tmp or a non-workspace clone.
Common situations: Running the recording script in isolation outside the repo; the script's CLI_ROOT resolution produced an unexpected path; pnpm-workspace.yaml was renamed or deleted.
Related errors
- vhs not found. Install: brew install charmbracelet/tap/vhs
- test-utils not found at ${testUtilsPath}.\nRun pnpm install
- CLI not built. Run 'pnpm build' first.\nExpected: ${CLI_BIN}
- Fixture app not found at ${FIXTURE_APP_DIR}.\nRun pnpm insta
- ${name} must be set
AI-assisted analysis of prisma/prisma@a20d61fb6f (2026-08-11).
Data as JSON: /api/errors/36607f70a1bd6f26.
Report an issue: GitHub.