{"record":{"id":"281f473f563f9c88","repo":"vercel/next.js","slug":"unsupported-package-manager-packagemanager","errorCode":null,"errorMessage":"Unsupported package manager: ${packageManager}","messagePattern":"Unsupported package manager: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/create-next-app/helpers/typegen.ts","lineNumber":38,"sourceCode":"        args = ['exec', 'next', '--', 'typegen']\n        break\n      case 'yarn':\n        command = 'yarn'\n        args = ['exec', 'next', '--', 'typegen']\n        break\n      case 'pnpm':\n        command = 'pnpm'\n        args = ['exec', 'next', '--', 'typegen']\n        break\n      case 'bun':\n        command = 'bun'\n        // Bun only has `bun x` which is not the same thing.\n        // We need to hope Bun never implements their own `bun next`.\n        args = ['next', 'typegen']\n        break\n      default:\n        packageManager satisfies never\n        throw new Error(`Unsupported package manager: ${packageManager}`)\n    }\n\n    const child = spawn(command, args, {\n      stdio: 'inherit',\n      env: {\n        ...process.env,\n      },\n    })\n\n    child.on('close', (code) => {\n      if (code !== 0) {\n        reject(new Error(`next typegen exited with code ${code}`))\n        return\n      }\n      resolve()\n    })\n  })\n}","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/create-next-app/helpers/typegen.ts#L20-L56","documentation":"create-next-app's `runTypegen` switches on the detected PackageManager to build the `next typegen` invocation; the `default` branch throws if the value is not one of npm/yarn/pnpm/bun. The `packageManager satisfies never` clause makes this a compile-time exhaustiveness check too, so at runtime this only fires if the PackageManager type was widened or a new manager was added without updating the switch.","triggerScenarios":"Calling `runTypegen()` with an unexpected string (e.g. an undefined, empty string, or a new manager like 'deno'); or a future type change that allows a value outside the four supported managers.","commonSituations":"A custom fork of create-next-app that added a PackageManager variant but forgot the case; passing a value read from a config without validation; `getPkgManager` returning an unexpected value due to a parsing bug.","solutions":["Ensure the PackageManager passed is one of 'npm' | 'yarn' | 'pnpm' | 'bun'.","If adding a new manager, extend the switch in `typegen.ts` (and the PackageManager type) before using it.","Validate the value before calling runTypegen and fall back to a supported manager or surface a clear error to the user.","Check `getPkgManager` output in the failing environment."],"exampleFix":"// before\nrunTypegen('deno' as any)\n\n// after\nif (['npm','yarn','pnpm','bun'].includes(pm)) {\n  await runTypegen(pm as PackageManager)\n} else {\n  throw new Error(`Use a supported package manager, got ${pm}`)\n}","handlingStrategy":"type-guard","validationCode":"const SUPPORTED = new Set(['npm','yarn','pnpm','bun'])\nfunction assertPm(pm: string): asserts pm is 'npm'|'yarn'|'pnpm'|'bun' {\n  if (!SUPPORTED.has(pm)) throw new Error(`Unsupported package manager: ${pm}`)\n}\nassertPm(packageManager)\nawait runTypegen(packageManager)","typeGuard":"function isPackageManager(pm: unknown): pm is 'npm'|'yarn'|'pnpm'|'bun' {\n  return typeof pm === 'string' && ['npm','yarn','pnpm','bun'].includes(pm)\n}","tryCatchPattern":null,"preventionTips":["Validate PackageManager before calling runTypegen.","Keep the switch exhaustive (the `satisfies never` already enforces this at compile time).","Add a case whenever a new manager is supported."],"tags":["create-next-app","typegen","package-manager","exhaustiveness","typescript"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}