vercel/turborepo · error · ConvertError

package_json-missing

package_json-missing

Error message

no "package.json" found at ${workspaceRoot}

What it means

getPackageJson() is the shared helper (used by workspace-manager detection, path expansion, and every adapter's read) that loads <workspaceRoot>/package.json via fs-extra's readJsonSync. When the underlying error carries code ENOENT, it is converted into ConvertError `no "package.json" found at <root>` with type package_json-missing.

Solutions

  1. Create a root package.json (npm init -y) if the repository has none
  2. Verify the directory you are running from and the workspace root passed to the tool
  3. Tighten workspace globs or add a package.json to every matched folder
  4. Restore a deleted package.json from git history

Example fix

// before: repo root has no package.json
$ turbo convert
// after: create a minimal manifest first
$ npm init -y && turbo convert
Defensive patterns

Strategy: validation

Validate before calling

import { existsSync } from "fs-extra";
import path from "node:path";
if (!existsSync(path.join(workspaceRoot, "package.json"))) {
  throw new Error(`missing manifest at ${workspaceRoot} — run npm init -y or fix the root`);
}

Type guard

function isConvertError(e: unknown): e is { type: string } {
  return typeof e === "object" && e !== null && "type" in e;
}

Try / catch

try {
  await readWorkspace(args);
} catch (e) {
  if (isConvertError(e) && e.type === "package_json-missing") {
    // the message names the offending workspaceRoot — create a package.json there or correct the root
  } else {
    throw e;
  }
}

Prevention

When it happens

Trigger: Any @turbo/workspaces read/convert call where the resolved workspaceRoot contains no package.json: passing the wrong root, an empty repository, or a workspaces glob that matches a directory without a manifest.

Common situations: Running the conversion tool in the wrong directory; a monorepo glob like "packages/*" matching non-package folders (docs, scripts, e2e fixtures); scaffolding a brand-new repo before creating the root manifest.

Related errors


AI-assisted analysis of vercel/turborepo@f9245100cf (2026-08-17). Data as JSON: /api/errors/2e3770dd6cdeb115. Report an issue: GitHub.

Appendix: source

Thrown at packages/turbo-workspaces/src/utils.ts:64

  "pnpm",
  "yarn",
  "bun",
  "nub",
  "aube"
]);

function getPackageJson({
  workspaceRoot
}: {
  workspaceRoot: string;
}): PackageJson {
  const packageJsonPath = path.join(workspaceRoot, "package.json");
  try {
    return readJsonSync(packageJsonPath, "utf8") as PackageJson;
  } catch (err) {
    if (err && typeof err === "object" && "code" in err) {
      if (err.code === "ENOENT") {
        throw new ConvertError(`no "package.json" found at ${workspaceRoot}`, {
          type: "package_json-missing"
        });
      }
      if (err.code === "EJSONPARSE") {
        throw new ConvertError(
          `failed to parse "package.json" at ${workspaceRoot}`,
          {
            type: "package_json-parse_error"
          }
        );
      }
    }
    throw new Error(
      `unexpected error reading "package.json" at ${workspaceRoot}`
    );
  }
}

View on GitHub (pinned to f9245100cf)