# Bun & Ultra-Fast Native Package Resolution

> Bun combines a JavaScript runtime with package installation and other development tools. Its package manager supports existing manifests and records resolutions in the text-based bun.lock file.

Subject: Package Managers | Lesson 15 of 24 | 5 min read
Interactive lesson: https://codewithanimation.in/package-managers/bun-package-manager
Previous: [pnpm & The Content-Addressable Store](https://codewithanimation.in/package-managers/pnpm-content-addressable-store.md) | Next: [Corepack & the packageManager Field](https://codewithanimation.in/package-managers/corepack-and-package-manager-field.md)

## What is it?

bun install is Bun's package-manager command for projects with a package.json. Its implementation and installation policies differ from npm, so test the workflow rather than assuming every npm behavior is identical.

Current Bun uses the text-based bun.lock by default. The historical bun.lockb was binary; this format difference should not be confused with Yarn's lockfile syntax.

## Why use it?

Installation time can matter in local development and CI. A different package manager may reduce that time, but results depend on the project, cache state, filesystem and machine.

Measure your own installation workload and check compatibility before switching. Implementation language alone does not establish a universal speed ratio.

## How it works

To use it, you install Bun and run `bun install` in any directory with a `package.json`.

Bun resolves the manifest, uses its package cache and writes its own lockfile. Linking behavior depends on the platform and selected backend. In CI, --frozen-lockfile refuses an install that would require a lockfile update.

## Common mistake: Distinguish the historical binary lockfile from the current text format

Bun 1.2 changed the default from binary bun.lockb to text-based bun.lock. Commit the intended lockfile and follow the documented migration workflow when changing formats.

## Tip: It's Not Just a Package Manager

Bun is also a bundler, a test runner (`bun test`), and a complete Node.js runtime replacement, aiming to be an all-in-one toolkit.

## Try it: Interactive Demo

Explore the concept in action using the interactive visualization below.

The animation is on the lesson page and is not part of this text version: https://codewithanimation.in/package-managers/bun-package-manager

## Check yourself

### Question 1

Which Bun command installs the dependencies declared by an existing project?

- A. bun test
- B. bun run server.js
- C. bun install
- D. npm publish

Correct answer: C

bun install is the package-manager operation. Bun also has separate runtime, test and build commands.

- Why not A: test runs tests rather than performing the project install.
- Why not B: This runs a script rather than the project install operation.
- Why not D: This is an npm publication command, not Bun installation.

### Question 2

Which statement distinguishes current Bun lockfiles from the historical format?

- A. bun.lock and bun.lockb are both always binary
- B. Bun never writes a lockfile
- C. bun.lock is the application's compiled bundle
- D. bun.lock is text-based; bun.lockb was the binary format

Correct answer: D

Bun changed its default to the text-based bun.lock in version 1.2. Do not infer the current format from the old .lockb extension.

- Why not A: The current default bun.lock is text-based.
- Why not B: bun install normally writes bun.lock.
- Why not C: It records installation resolutions, not application output.

### Question 3

What should bun install --frozen-lockfile do if the manifest would require changing the lockfile?

- A. Fail instead of updating the lockfile
- B. Silently rewrite the lock to the newest versions
- C. Publish the project to the registry
- D. Guarantee the application has no runtime bugs

Correct answer: A

Frozen installation checks the existing lock against the manifest and avoids rewriting dependency resolutions. This supports controlled CI installs.

- Why not B: That would violate the frozen-lockfile constraint.
- Why not C: Installation does not publish the package.
- Why not D: Locked installation is not a correctness proof.

## Remember this

- Compare package-manager performance on the actual project rather than assuming a fixed speedup.
- Current bun install normally writes the text-based bun.lock; bun.lockb is the historical binary format.
- Use --frozen-lockfile when CI must refuse changes to the resolved lockfile.
- Bun is more than a package manager; it's a runtime, test runner, and bundler.
