Bun: Working with packages

Since Bun is meant to interoperate with Node.js, and be compatible with it, it uses npm.

This gives Bun access to a billion npm packages already published, that typically just work in Bun too (unless they use unsupported APIs)

As Node.js, it also uses package.json to store information about packages in your project.

So you can run bun install (or bun i) to install all dependencies of a project in node_modules.

You can add a package using bun add <package>.

Remove a package using bun remove <package>

Update a package using bun update <package>

Update all packages using bun update

Packages are installed in the folder you’re in. To install globally, just like for Node.js, use the -g flag: bun add -g <package> and bun remove -g <package>.

Lessons in this unit:

0: Introduction
1: Installing Bun
2: Running your first Bun program
3: ▶︎ Working with packages
4: Bun's built-in features
Want to learn more? Check out our courses