vercel/turborepo · error
New workspace root detected - unexpected pnpm-workspace.yaml
Error message
New workspace root detected - unexpected pnpm-workspace.yaml
What it means
The turbo-gen copy generator rejects copy sources that are themselves monorepo roots. Besides the workspaces field, it treats a pnpm-workspace.yaml at the destination root as proof of a nested monorepo. It throws this Error when that file exists after the copy, then logs it and deletes the copied directory.
Solutions
- Copy a single package from inside the pnpm monorepo by setting the example path to that package directory
- If you own the source and it is truly a single package, delete or rename the pnpm-workspace.yaml and commit a workspace.yml-free variant
- Pick a different example that is not a workspace root
Example fix
# before: copy a pnpm monorepo root npm exec turbo gen -- --copy https://github.com/org/pnpm-monorepo # after: copy one workspace from it npm exec turbo gen -- --copy https://github.com/org/pnpm-monorepo --example-path packages/ui
Defensive patterns
Strategy: validation
Validate before calling
import fs from "node:fs";
// reject copy sources that carry pnpm workspace manifests
if (fs.existsSync(path.join(sourceDir, "pnpm-workspace.yaml"))) {
throw new Error("Copy source is a pnpm monorepo root; choose one of its packages");
} Type guard
function isPnpmWorkspaceRoot(dir: string): boolean {
return fs.existsSync(`${dir}/pnpm-workspace.yaml`);
} Prevention
- Check for pnpm-workspace.yaml when vetting external examples
- Copy a single workspace from monorepo examples via the example path
- Keep single-package examples free of workspace manifest files
When it happens
Trigger: The external example copied into your monorepo contains a pnpm-workspace.yaml at its root. The existsSync check after the package.json validation finds the file and throws. The generator rolls back the destination directory.
Common situations: Copying a pnpm-based monorepo example instead of one of its packages. An example that ships a pnpm-workspace.yaml for tooling reasons even though it is a single package.
Related errors
- New workspace root detected - unexpected 'workspaces' field…
- New workspace is missing a package.json file
- plop_error_running_generator
- plop_generator_not_found
- Workspace " " not found
AI-assisted analysis of vercel/turborepo@f9245100cf (2026-08-17).
Data as JSON: /api/errors/c06a4429cfcce9b7.
Report an issue: GitHub.
Appendix: source
Thrown at packages/turbo-gen/src/generators/copy.ts:51
examplePath: opts.examplePath
});
try {
if (fs.existsSync(newPackageJsonPath)) {
const packageJson = (await fs.readJSON(
newPackageJsonPath
)) as PackageJson;
if (packageJson.workspaces) {
throw new Error(
"New workspace root detected - unexpected 'workspaces' field in package.json"
);
}
} else {
throw new Error("New workspace is missing a package.json file");
}
if (fs.existsSync(path.join(location.absolute, "pnpm-workspace.yaml"))) {
throw new Error(
"New workspace root detected - unexpected pnpm-workspace.yaml"
);
}
} catch (err) {
let message = "UNKNOWN_ERROR";
if (err instanceof Error) {
message = err.message;
}
logger.error(message);
// rollback changes
await fs.rm(location.absolute, { recursive: true, force: true });
return;
}
} else if (source) {
const filterFunc: CopyFilterAsync = async (src) =>
!src.includes("node_modules");
View on GitHub (pinned to f9245100cf)