bun install is a Node.js compatible npm client designed to be an incredibly fast successor to npm.
We’ve put a lot of work into making sure that the migration path from npm install to bun install is as easy as running bun install instead of npm install.
- Designed for Node.js & Bun:
bun installinstalls a Node.js compatiblenode_modulesfolder. You can use it in place ofnpm installfor Node.js projects without any code changes and without using Bun’s runtime. - Automatically converts
package-lock.jsonto bun’sbun.locklockfile format, preserving your existing resolved dependency versions without any manual work on your part. You can secretly usebun installin place ofnpm installat work without anyone noticing. .npmrccompatible: bun install reads npm registry configuration from npm’s.npmrc, so you can use the same configuration for both npm and Bun.- Hardlinks: On Windows and Linux,
bun installuses hardlinks to conserve disk space and install times.
terminal
Run package.json scripts faster
Run scripts from package.json, executables fromnode_modules/.bin (sort of like npx), and JavaScript/TypeScript files (just like node) - all from a single simple command.
| NPM | Bun |
|---|---|
npm run <script> | bun <script> |
npm exec <bin> | bun <bin> |
node <file> | bun <file> |
npx <package> | bunx <package> |
bun run <executable>, it will choose the locally-installed executable
terminal
Workspaces? Yes.
bun install supports workspaces similarly to npm, with more features.
In package.json, you can set "workspaces" to an array of relative paths.
package.json
Filter scripts by workspace name
In Bun, the--filter flag accepts a glob pattern, and will run the command concurrently for all workspace packages with a name that matches the pattern, respecting dependency order.
terminal
Update dependencies
To update a dependency, you can usebun update <package>. This will update the dependency to the latest version that satisfies the semver range specified in package.json.
terminal
View outdated dependencies
To view outdated dependencies, runbun outdated. This is like npm outdated but with more compact output.
terminal
List installed packages
To list installed packages, you can usebun pm ls. This will list all the packages that are installed in the node_modules folder using Bun’s lockfile as the source of truth. You can pass the -a flag to list all installed packages, including transitive dependencies.
terminal
terminal
Create a package tarball
To create a package tarball, you can usebun pm pack. This will create a tarball of the package in the current directory.
terminal
Shebang
If the package referencesnode in the #!/usr/bin/env node shebang, bun run will by default respect it and use the system’s node executable. You can force it to use Bun’s node by passing --bun to bun run.
When you pass --bun to bun run, we create a symlink to the locally-installed Bun executable named "node" in a temporary directory and add that to your PATH for the duration of the script’s execution.
terminal
Global installs
You can install packages globally usingbun i -g <package>. This will install into a .bun/install/global/node_modules folder inside your home directory by default.
terminal