DEV Community

Cover image for Why I Built bunpm: Route npm, yarn & pnpm Through Bun Without Touching Your Scripts
YASH VISHWAKARMA
YASH VISHWAKARMA

Posted on

Why I Built bunpm: Route npm, yarn & pnpm Through Bun Without Touching Your Scripts

Every JavaScript developer knows the feeling: you clone a project, run npm install, and wait while your fans start sounding like a jet engine.

Then Bun arrived with its lightning-fast native package manager, and running bun install felt like magic (seconds instead of minutes).

The catch?
Muscle memory is hard to rewrite. Your team still types npm install, npx, yarn add, or pnpm. Your legacy CI/CD scripts still have npm test. And if you try to simply alias npm=bun, things break the moment you hit npm-specific flags, lifecycle scripts, or Yarn PnP workspaces.

That's why I built bunpm — a zero-runtime-dependency CLI wrapper that transparently routes npm, npx, yarn, and pnpm commands through Bun, while falling back safely to the original manager whenever a command cannot be mapped 100% safely.


⚡ What It Does

When you type:

  • npm install ➔ translates directly to bun install
  • npm install express ➔ translates to bun add express
  • npx rimraf dist ➔ runs via bun x rimraf dist
  • yarn add react / pnpm add react ➔ runs via bun add react

And what if something isn't supported?
If you run something Bun cannot map safely (like npm audit, npm version, complex workspace filtering, or npm-specific flags like --save=false), bunpm never guesses. It instantly and silently falls back to your native npm / yarn / pnpm.

Zero breaking changes. Zero workflow disruptions.


🛠️ Key Engineering Principles

  1. Zero Runtime Dependencies ("dependencies": {}):
    No bloated node_modules just to run a CLI wrapper. It uses pure Node.js (CommonJS, Node 16.9+) standard library with zero third-party packages at runtime.

  2. Smart Stream Formatting:
    Piped and non-interactive output is cosmetically reformatted line-by-line to look familiar, bounded to a 64 KiB memory ceiling so it never buffers infinitely.

  3. POSIX Signal Forwarding & Child Process Safety:
    SIGINT (Ctrl+C) and SIGTERM signals are cleanly forwarded to the running child process, properly restoring terminal handlers upon exit.

  4. 100% Tested & Cross-Platform:

    • 99 automated test suites running across Ubuntu, macOS, and Windows on every push.
    • 100% statement and line test coverage enforced via c8.
    • Native shell launchers for bash, zsh, and Windows PowerShell.

🚀 Getting Started

You can install it offline from the repository:

git clone https://github.com/yv3000/bunpm.git
cd bunpm
Enter fullscreen mode Exit fullscreen mode

On Linux & macOS:

bash bunpm/platforms/linux/scripts/install.sh
Enter fullscreen mode Exit fullscreen mode

On Windows (PowerShell):

powershell -ExecutionPolicy Bypass -File .\bunpm\platforms\windows\scripts\install.ps1
Enter fullscreen mode Exit fullscreen mode

Once installed, verify the setup with:

bunpm doctor
Enter fullscreen mode Exit fullscreen mode

Now, just type npm install or yarn add like you always do — and enjoy the speed boost!


bunpm is completely open source under the MIT license. Check it out on GitHub, submit issues, or give it a star if you find it helpful!

👉 GitHub: github.com/yv3000/bunpm

Would love to hear your thoughts in the comments! How are you handling the transition to Bun in your team's workflow?

Top comments (0)