Overview

Bun is a fast all-in-one JavaScript runtime that includes a bundler, transpiler, package manager, and test runner. It is designed to be a complete toolkit for JavaScript and TypeScript development, offering significant performance improvements over existing tools.

Bun is built with the goal of providing an integrated development experience, combining multiple tools into a single package.

Installation

There are multiple ways to install Bun. In this guide, we will show the three easiest methods for installing Bun. You can find information on other methods here.


Open your terminal and run this command

npm install -g bun

The above command will install Bun

Run this command to verify if Bun is installed

  bun -v

It should show something like 1.1.18

Usage

Initializing a Project

bun init

This command initializes a new project and creates a bun.lockb file along with a package.json file.


Installing a Package

bun install <package_name>

This command installs a package locally in your project and updates the package.json and bun.lockb files.

Example

bun install axios

This installs the axios package, a promise-based HTTP client for the browser and Node.js.


Updating a Package

bun update <package_name>

This command updates a package to the latest version. If no package name is specified, it updates all project dependencies.

Example

bun update axios

This updates the axios package to its latest version.


Uninstalling a Package

bun remove <package_name>

This command removes a package from your project and updates the package.json and bun.lockb files accordingly.

Example

bun remove axios

This uninstalls the axios package.