{"record":{"id":"6f6cfa79ff3ab379","repo":"vercel/turborepo","slug":"package-manager-unable-to-detect","errorCode":"package_manager-unable_to_detect","errorMessage":"Could not determine package manager. Add `devEngines.packageManager` or legacy `packageManager` to `package.json`, or ensure a lockfile is present.","messagePattern":"Could not determine package manager\\. Add `devEngines\\.packageManager` or legacy `packageManager` to `package\\.json`, or ensure a lockfile is present\\.","errorType":"exception","errorClass":"ConvertError","httpStatus":null,"severity":"error","filePath":"packages/turbo-workspaces/src/get-workspace-details.ts","lineNumber":30,"sourceCode":"    directory: root\n  });\n  if (!exists) {\n    throw new ConvertError(\n      `Could not find directory at ${workspaceRoot}. Ensure the directory exists.`,\n      {\n        type: \"invalid_directory\"\n      }\n    );\n  }\n\n  for (const { detect, read } of Object.values(MANAGERS)) {\n    // eslint-disable-next-line no-await-in-loop -- we want to run serially and bail on the first success\n    if (await detect({ workspaceRoot })) {\n      return read({ workspaceRoot });\n    }\n  }\n\n  throw new ConvertError(\n    \"Could not determine package manager. Add `devEngines.packageManager` or legacy `packageManager` to `package.json`, or ensure a lockfile is present.\",\n    {\n      type: \"package_manager-unable_to_detect\"\n    }\n  );\n}\n","sourceCodeStart":12,"sourceCodeEnd":37,"githubUrl":"https://github.com/vercel/turborepo/blob/9f94a7d215b3881942527dd526afa3fc650869d5/packages/turbo-workspaces/src/get-workspace-details.ts#L12-L37","documentation":"After confirming the directory exists, getWorkspaceDetails() iterates the MANAGERS map (npm, pnpm, yarn, bun, nub, aube, ...) running each detect() — lockfile presence and/or a declared package manager field. If none claims the workspace it throws ConvertError type package_manager-unable_to_detect with remediation hints in the message.","triggerScenarios":"A workspace with no recognized lockfile (package-lock.json, pnpm-lock.yaml, yarn.lock, bun.lockb/bun.lock, ...) and no devEngines.packageManager or legacy packageManager field in package.json.","commonSituations":"Fresh repo initialized but never installed; lockfile deleted or gitignored; obscure or internal managers (nub/aube) without their lockfiles present; package.json stripped by scaffolding.","solutions":["Declare the manager in package.json: \"packageManager\": \"pnpm@9.1.0\" or \"devEngines\": { \"packageManager\": { \"type\": \"npm\", \"version\": \"10.4.0\" } }","Run one install with your manager so its lockfile exists, then retry","Restore the lockfile from git history if it was accidentally deleted"],"exampleFix":"// before: package.json has neither field, no lockfile on disk\n{}\n\n// after\n{\n  \"packageManager\": \"pnpm@9.1.0\"\n}","handlingStrategy":"validation","validationCode":"import { existsSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\n\nconst lockfiles = [\"package-lock.json\", \"pnpm-lock.yaml\", \"yarn.lock\", \"bun.lockb\", \"bun.lock\"];\nconst root = path.resolve(dir);\nconst pkg = JSON.parse(readFileSync(path.join(root, \"package.json\"), \"utf8\"));\nconst declared = pkg?.devEngines?.packageManager ?? pkg?.packageManager;\nconst hasLockfile = lockfiles.some((f) => existsSync(path.join(root, f)));\nif (!declared && !hasLockfile) {\n  throw new Error(\"Declare a package manager or commit a lockfile before workspace detection\");\n}","typeGuard":"function isManagerUndetectedError(e: unknown): boolean {\n  return e instanceof ConvertError && e.type === \"package_manager-unable_to_detect\";\n}","tryCatchPattern":"try {\n  await getWorkspaceDetails({ root });\n} catch (e) {\n  if (e instanceof ConvertError && e.type === \"package_manager-unable_to_detect\") {\n    // prompt the user to pick a manager, write packageManager to package.json, retry\n  } else throw e;\n}","preventionTips":["Commit at least one lockfile and/or declare packageManager in package.json from day one","Don't gitignore lockfiles in application repos","Interactive tools should catch this error and offer to write the field for the user"],"tags":["package-manager","detection","lockfile","workspace"],"backgroundTag":"package-manager-not-detected","analyzedSha":"9f94a7d215b3881942527dd526afa3fc650869d5","analyzedAt":"2026-08-16T19:47:29.531Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}