Safeguard
Developer Tools•

bun.lock or bun.lockb: which Bun lockfile should you commit?

Bun v1.2 made the text based bun.lock the default. Here is which file to commit, how to migrate from bun.lockb, and what that means for scanning.

Safeguard Security Team
3 min read

Commit bun.lock. Since Bun v1.2 the default lockfile is the text based bun.lock, which can be read in a code review and by tools. The older binary bun.lockb can be migrated with one command and then deleted. Keeping a readable lockfile in git makes dependency changes reviewable.

What the Bun documentation says

The Bun docs state that bun install creates a lockfile called bun.lock and that it should be committed to git. They also say Bun v1.2 changed the default format to the text based bun.lock. If you still have a binary bun.lockb, the documented migration is bun install --save-text-lockfile --frozen-lockfile --lockfile-only, after which you delete bun.lockb.

Why does the format matter for security? A binary file cannot be diffed in a pull request. A text file can. When a reviewer sees a lockfile change that adds an unexpected package or moves a version, they have something to question. With a binary lockfile, that visibility is gone, and any tool that wants to read the resolved versions has to understand the binary layout.

Migration steps

  1. Check which file you have: bun.lock (text) or bun.lockb (binary).
  2. If you have only bun.lockb, run the migration command from the docs.
  3. Confirm bun.lock appears and the install still works.
  4. Delete bun.lockb and commit bun.lock.
  5. In CI, use bun install --frozen-lockfile so the build fails if the lockfile and package.json disagree. The docs note that frozen mode saves nothing to disk.

Moving from another package manager

Bun can migrate other lockfiles automatically when no bun.lock exists. The docs list yarn.lock (Yarn v1 and Yarn 2 plus), npm-shrinkwrap.json and package-lock.json (lockfileVersion 2, 3 or 4), and pnpm-lock.yaml. If several exist, Bun migrates the first one it finds in this order: npm-shrinkwrap.json, package-lock.json, yarn.lock, pnpm-lock.yaml, and prints a warning for each it skips.

Two details deserve attention. An npm lockfile from npm 6 or older (lockfileVersion 1) is not migrated, and Bun resolves from package.json instead, which means versions may differ from what you had. And Bun preserves the original lockfile, so after verifying, remove the old one yourself. Leaving two lockfiles in a repository invites confusion about which one is authoritative, and some tools will read the wrong one.

SituationWhat to do
Only bun.lockbMigrate to bun.lock, delete the binary
bun.lock plus an old yarn.lockRemove the old file after verifying
Migrated from npm lockfileVersion 1Compare resolved versions, they may have changed
CI installsUse the frozen lockfile flag

What a scanner needs

A scanner that reads lockfiles needs a format it supports. Before you switch package managers, check that your scanning tool can read the lockfile you intend to commit, and run it once on the migrated project. Compare the package count and key versions with the previous lockfile. Differences are worth a look, since migration can change which versions are resolved.

Safeguard's SBOM and dependency scanning produces an inventory for your projects, and the free scan lets you check how your repository looks to it before you commit to a change.

Quick check

Is bun.lockb still supported?

The docs describe it as the older binary format and give a migration path to bun.lock. Plan to migrate rather than rely on it.

What if I have both package-lock.json and yarn.lock?

Bun migrates the first it finds in its documented order, which puts package-lock.json before yarn.lock, and warns about the others.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.