vercel/next.js · error

Unsupported package manager: ${packageManager}

Error message

Unsupported package manager: ${packageManager}

What it means

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.

Source

Thrown at packages/create-next-app/helpers/typegen.ts:38

        args = ['exec', 'next', '--', 'typegen']
        break
      case 'yarn':
        command = 'yarn'
        args = ['exec', 'next', '--', 'typegen']
        break
      case 'pnpm':
        command = 'pnpm'
        args = ['exec', 'next', '--', 'typegen']
        break
      case 'bun':
        command = 'bun'
        // Bun only has `bun x` which is not the same thing.
        // We need to hope Bun never implements their own `bun next`.
        args = ['next', 'typegen']
        break
      default:
        packageManager satisfies never
        throw new Error(`Unsupported package manager: ${packageManager}`)
    }

    const child = spawn(command, args, {
      stdio: 'inherit',
      env: {
        ...process.env,
      },
    })

    child.on('close', (code) => {
      if (code !== 0) {
        reject(new Error(`next typegen exited with code ${code}`))
        return
      }
      resolve()
    })
  })
}

View on GitHub (pinned to 0ae8c72462)

Solutions

  1. Ensure the PackageManager passed is one of 'npm' | 'yarn' | 'pnpm' | 'bun'.
  2. If adding a new manager, extend the switch in `typegen.ts` (and the PackageManager type) before using it.
  3. Validate the value before calling runTypegen and fall back to a supported manager or surface a clear error to the user.
  4. Check `getPkgManager` output in the failing environment.

Example fix

// before
runTypegen('deno' as any)

// after
if (['npm','yarn','pnpm','bun'].includes(pm)) {
  await runTypegen(pm as PackageManager)
} else {
  throw new Error(`Use a supported package manager, got ${pm}`)
}
Defensive patterns

Strategy: type-guard

Validate before calling

const SUPPORTED = new Set(['npm','yarn','pnpm','bun'])
function assertPm(pm: string): asserts pm is 'npm'|'yarn'|'pnpm'|'bun' {
  if (!SUPPORTED.has(pm)) throw new Error(`Unsupported package manager: ${pm}`)
}
assertPm(packageManager)
await runTypegen(packageManager)

Type guard

function isPackageManager(pm: unknown): pm is 'npm'|'yarn'|'pnpm'|'bun' {
  return typeof pm === 'string' && ['npm','yarn','pnpm','bun'].includes(pm)
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of vercel/next.js@0ae8c72462 (2026-08-06). Data as JSON: /api/errors/281f473f563f9c88. Report an issue: GitHub.