nextjs - 💡(How to fix) Fix getPkgManager does not detect Bun, falls back to npm causing build failure in Bun-only environments

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

  1. See error: npm: not found

Code Example

- Next.js 16.2.6
- Bun 1.3.9
- Docker: oven/bun:1.3.9 image
- OS: Fedora (host), Alpine (container)
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/vercel/next.js/blob/canary/packages/next/src/lib/helpers/get-pkg-manager.ts

To Reproduce

  1. Use Bun as package manager (bun.lock present)
  2. Build Next.js in a Docker container using oven/bun image (no npm)
  3. Run next build
  4. See error: npm: not found

Current vs. Expected behavior

Current

getPkgManager checks for these lockfiles:

  • yarn.lock → yarn
  • pnpm-lock.yaml → pnpm
  • package-lock.json → npm

bun.lock and bun.lockb are not checked, so it falls back to npm by default, then executes npm config get registry which fails in Bun-only environments.

Expected behaviour

getPkgManager should also check for Bun lockfiles:

  • bun.lock → bun
  • bun.lockb → bun

And execute bun config get registry instead of npm config get registry.

Provide environment information

- Next.js 16.2.6
- Bun 1.3.9
- Docker: oven/bun:1.3.9 image
- OS: Fedora (host), Alpine (container)

Which area(s) are affected? (Select all that apply)

Not sure

Which stage(s) are affected? (Select all that apply)

next build (local)

Additional context

The bug is reproducible in a Docker multi-stage build environment where the oven/bun image is used for installing dependencies. Since the bun image does not include npm, and getPkgManager falls back to npm, the build fails.

The fix is straightforward — add bun.lock and bun.lockb to the lockfile detection list in get-pkg-manager.ts.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING