I want to read yarn.lock file and generate bun.lockb from that with the same dependencies to be used in bun install, without this bun is creating the deps based on package.json and is big projects (specially typescript projects) it brings lost of type conflicts.
yarn.lock MigrationBun now natively supports migrating yarn.lock (v1) files to its own binary lockfile. You only need to run bun install in your project, and Bun will automatically generate a bun.lockb file by preserving the resolved dependency versions from yarn.lock.
Steps:
Make sure you are using Bun v1.2.20 or later (bun --version).
Simply run:
bun install
This will migrate dependencies from yarn.lock to bun.lockb automatically.
If unsure about your Bun version, upgrade with:
bun upgrade
Reference:
synp and bun pm migrateFor users unable to upgrade to Bun v1.2.20, you can migrate yarn.lock to bun.lockb with a more manual process:
Bun (since version 1.0.5) supports migrating package-lock.json to bun.lockb as seen in this pull request. However, the support for migrating <s>yarn.lock</s> is not implemented yet. You can track the progress on this issue.
As an intermediate step, we can use synp, a tool that converts yarn.lock to package-lock.json.
Here's the detailed steps:
# convert yarn.lock to package-lock.json using synp
npx synp --source-file yarn.lock
# upgrade package-lock.json to version 3 using npm
npm i --lockfile-version 3 --frozen-lockfile
# convert package-lock.json to bun.lockb using bun
bun pm migrate
This workflow relies on the intermediate conversion to a package-lock.json file and then leverages Bun’s migration support for npm lockfiles.
| Bun Version | Supports yarn.lock directly? | Recommended Migration Method |
|---|---|---|
| ≥ 1.2.20 | Yes | Run bun install |
| < 1.2.20 | No | Use synp → package-lock.json → Bun |