{"record":{"id":"2e3770dd6cdeb115","repo":"vercel/turborepo","slug":"package-json-missing","errorCode":"package_json-missing","errorMessage":"no \"package.json\" found at ${workspaceRoot}","messagePattern":"no \"package\\.json\" found at (.+?)","errorType":"exception","errorClass":"ConvertError","httpStatus":null,"severity":"error","filePath":"packages/turbo-workspaces/src/utils.ts","lineNumber":64,"sourceCode":"  \"pnpm\",\n  \"yarn\",\n  \"bun\",\n  \"nub\",\n  \"aube\"\n]);\n\nfunction getPackageJson({\n  workspaceRoot\n}: {\n  workspaceRoot: string;\n}): PackageJson {\n  const packageJsonPath = path.join(workspaceRoot, \"package.json\");\n  try {\n    return readJsonSync(packageJsonPath, \"utf8\") as PackageJson;\n  } catch (err) {\n    if (err && typeof err === \"object\" && \"code\" in err) {\n      if (err.code === \"ENOENT\") {\n        throw new ConvertError(`no \"package.json\" found at ${workspaceRoot}`, {\n          type: \"package_json-missing\"\n        });\n      }\n      if (err.code === \"EJSONPARSE\") {\n        throw new ConvertError(\n          `failed to parse \"package.json\" at ${workspaceRoot}`,\n          {\n            type: \"package_json-parse_error\"\n          }\n        );\n      }\n    }\n    throw new Error(\n      `unexpected error reading \"package.json\" at ${workspaceRoot}`\n    );\n  }\n}\n","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/vercel/turborepo/blob/f9245100cf0d31d96628804ead485f6bf226e55a/packages/turbo-workspaces/src/utils.ts#L46-L82","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Create a root package.json (npm init -y) if the repository has none","Verify the directory you are running from and the workspace root passed to the tool","Tighten workspace globs or add a package.json to every matched folder","Restore a deleted package.json from git history"],"exampleFix":"// before: repo root has no package.json\n$ turbo convert\n// after: create a minimal manifest first\n$ npm init -y && turbo convert","handlingStrategy":"validation","validationCode":"import { existsSync } from \"fs-extra\";\nimport path from \"node:path\";\nif (!existsSync(path.join(workspaceRoot, \"package.json\"))) {\n  throw new Error(`missing manifest at ${workspaceRoot} — run npm init -y or fix the root`);\n}","typeGuard":"function isConvertError(e: unknown): e is { type: string } {\n  return typeof e === \"object\" && e !== null && \"type\" in e;\n}","tryCatchPattern":"try {\n  await readWorkspace(args);\n} catch (e) {\n  if (isConvertError(e) && e.type === \"package_json-missing\") {\n    // the message names the offending workspaceRoot — create a package.json there or correct the root\n  } else {\n    throw e;\n  }\n}","preventionTips":["Always create a root package.json before running workspace tooling","Keep workspaces globs (packages/*, apps/*) pointing only at directories that contain manifests","Check git status for accidentally deleted manifests before converting"],"tags":["package-json","filesystem","workspace","migration"],"backgroundTag":"package-json-not-found","analyzedSha":"f9245100cf0d31d96628804ead485f6bf226e55a","analyzedAt":"2026-08-17T10:46:15.696Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}