Bun.sh as a Package Manager
Welcome back fellows, If you read the first part of our Bun.sh series, you know we are on a mission to cure the fatigue of modern javascript development.
When you spend hours navigating the realities of life behind the keyboard, every second waiting for a command to execute breaks your flow state. Today, I am putting on my QCY C30 headset, queuing up a focus playlist, and showing you how Bun aggressively optimizes the two things we do most: installing packages and running scripts.
Let's look at how Bun completely replaces npm, yarn, ts-node, and nodemon—and the actual speed differences you will see.
1. The Death of the "npm install" Coffee Break
We have all been there: you clone a new repository, type npm install, and walk away to make a coffee because you know it is going to take a while to resolve all those nested dependencies. Don't worry, Our coffee breaks nowadays can happen when tools like cursor/claude are working 😄
Bun acts as a drop-in replacement for npm or yarn. It uses a global cache and operating system-level hard links, meaning if you have downloaded a package once for any project on your machine, Bun doesn't download it again. It just links to it.
The Real-World Benchmark: Let's take a standard Next.js template installation on a fresh project (removing the node_modules and lockfile beforehand to test a cold cache):
- npm install: ~28.5 seconds
- yarn install: ~22.3 seconds
- bun install: ~1.2 seconds
Yes, you read that right. By swapping npm install for bun install, the process is so fast that you barely have time to blink, let alone grab a coffee.
2. Replacing ts-node: Running TypeScript Natively
In the traditional Node.js world, if you want to execute a .ts file, you usually have to install ts-node or tsx. Not only does this add bloat to your package.json, but the cold start times for these transpilers can be painfully slow.
With Bun, TypeScript is treated as a first-class citizen.
How you do it in Node.js:
Bash
npx ts-node src/index.ts
(Waiting 2-3 seconds just for the engine to transpile the file before it even starts executing your code).
How you do it in Bun:
Bash
bun run src/index.ts
Bun executes the file instantly. Because it parses TypeScript and JSX internally via native code (written in Zig), the overhead of starting a script is measured in microseconds, completely bypassing the heavy transpilation pipeline.
3. Ditching nodemon: Built-in Hot Reloading
When developing an API, you want your server to automatically restart whenever you save a file. Historically, we relied on nodemon to watch our directories and kill/restart the Node process.
Bun eliminates the need for third-party watchers entirely with its native --watch flag or --hot
Instead of configuring nodemon:
Bash
bun --watch run src/index.ts
When you hit save on your file, Bun restarts the process incredibly fast. Because Bun's startup time is magnitudes faster than Node's, hot-reloading feels virtually instantaneous. It keeps you right in the zone, making programming a much smoother experience.
4. Zero-Overhead package.json Scripts
Even if you are just running standard scripts from your package.json (like npm run dev or npm run build), npm introduces a noticeable delay—roughly 150ms to 200ms of overhead just to parse the file and start the execution.
Running bun run <script> takes that overhead down to about 7 milliseconds. It might sound trivial, but when you run scripts dozens of times an hour, stripping away that latency makes your terminal feel infinitely more responsive.
Conclusion: Reclaiming Your Time
By acting as your package manager, your TypeScript runner, and your file watcher, Bun clears out the clutter from your toolchain. You get to delete ts-node, nodemon, and yarn from your workflow, all while enjoying benchmarks that are 20x to 30x faster.
In the next part of this series, we are going to take all this speed and actually build something with it. We will be constructing a REST API using Elysia.js.
Have you tried running bun install on one of your heavier projects yet? Let me know in the comments how many seconds it shaved off your usual wait time!