# Bun

> The Bun is a fast all-in-one JavaScript runtime with a built-in package manager, bundler and test runner.

## What is Bun and can it replace Node.js and npm?

The JS runtime with a built-in package manager, bundler and test runner. It is compatible with most npm packages and Node.js APIs and can be used as a drop-in replacement for many Node.js workflows.

- Topic: Package Managers
- Type: tool, package manager

## Example

Wrong:

```bash
npm install
bun install
```

Right:

```bash
bun install --frozen-lockfile
bun run build
```

Sticking to Bun keeps one lock file, and `--frozen-lockfile` fails the build instead of changing versions.

## Common mistakes

- Mixing Bun and npm installs in one project, leaving two lock files out of sync.

## Key points

- The Bun lock file is committed, and CI installs with `bun install --frozen-lockfile`.
- Scripts in `package.json` run through `bun run`, and one-off tools through `bunx` instead of `npx`.
- Native Node addons and Node-specific APIs the project depends on are tested under Bun before switching.

## Interview questions

### Can Bun run TypeScript files directly?

Yes. Bun transpiles TypeScript and JSX on the fly without extra config, but it does not type check, so run `tsc --noEmit` for that.

### Can I use Bun only as a package manager?

Yes. `bun install` works in a Node project, and the app can still run on Node.

### What is bunx?

`bunx` runs a package binary like `npx` does, downloading it to a cache when it is not installed locally.

## Related cards

- [Package Managers](https://wonderium.dev/processes/package-managers.md)
- [npm](https://wonderium.dev/processes/npm.md)
- [pnpm](https://wonderium.dev/processes/pnpm.md)
- [Lock file](https://wonderium.dev/processes/lock-file.md)
- [Type Stripping](https://wonderium.dev/ts/type-stripping.md)

---

- Level: [Processes](https://wonderium.dev/processes.md)
- HTML version: https://wonderium.dev/processes/bun
- Last updated: 2026-11-25
