bun-pm-migrate
TLDR
Migrate the lockfile in the current project
SYNOPSIS
bun pm migrate
DESCRIPTION
bun pm migrate is a utility from Bun, the all-in-one JavaScript runtime, bundler, and package manager. It automates the conversion of lockfiles from popular package managers to Bun's optimized bun.lockb binary format, enabling faster installs and better reproducibility.
The command scans the current directory for common lockfiles like package-lock.json (npm), yarn.lock (Yarn v1/v2), or pnpm-lock.yaml (pnpm), detects the source, and generates an equivalent bun.lockb. It preserves dependencies, resolutions, and integrity hashes where possible, while updating package.json scripts or fields for Bun compatibility.
Post-migration, run bun install to use the new lockfile. This tool lowers the barrier for adopting Bun in legacy Node.js projects, leveraging Bun's speed (up to 30x faster than npm). It's non-destructive but recommends backing up originals.
Ideal for monorepos or large projects seeking performance gains without manual refactoring.
CAVEATS
Auto-detects lockfile type; supports only npm, Yarn v1/v2, pnpm.
Backup existing lockfiles first.
May require manual fixes for exotic resolutions or peer deps.
Experimental for Yarn v3+ Plug'n'Play.
SUPPORTED SOURCES
npm: package-lock.json (v2/v3)
Yarn v1: yarn.lock
Yarn v2/v3: yarn.lock + .pnp.*
pnpm: pnpm-lock.yaml
USAGE EXAMPLE
cd my-project
bun pm migrate
bun install
Commit bun.lockb to git.
HISTORY
Introduced in Bun v0.1.0 (September 2022) by Jarred Sumner to facilitate adoption. Evolved with Bun 1.0 (2023) for production stability, aligning with Bun's goal of replacing Node.js tools.


