Search code examples
yarnpkgbun

Migrate yarn.lock dependencies to bun.lockb file


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.


Solution

  • 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 yarn.lock 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