bun install is a fast, Node.js-compatible npm client.
To migrate from npm install to bun install, run 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. You can secretly usebun installin place ofnpm installat work without anyone noticing. .npmrccompatible:bun installreads 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 save disk space and speed up installs.
terminal
Run package.json scripts faster
Run scripts frompackage.json, executables from node_modules/.bin (like npx), and JavaScript/TypeScript files (like node), all with a single command.
| NPM | Bun |
|---|---|
npm run <script> | bun <script> |
npm exec <bin> | bun <bin> |
node <file> | bun <file> |
npx <package> | bunx <package> |
bun run <executable> uses the locally-installed executable.
terminal
Workspaces? Yes.
bun install supports workspaces similarly to npm, with more features.
In package.json, 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 runs the command concurrently for every workspace package whose name matches it, respecting dependency order.
terminal
Update dependencies
bun update <package> updates a dependency to the latest version that satisfies the semver range in package.json.
terminal
View outdated dependencies
To view outdated dependencies, runbun outdated. It works like npm outdated, with more compact output.
terminal
List installed packages
bun pm ls lists the packages installed in the node_modules folder, using Bun’s lockfile as the source of truth. Pass the -a flag to also list transitive dependencies.
terminal
terminal
Create a package tarball
bun pm pack creates a tarball of the package in the current directory.
terminal
Shebang
If the package referencesnode in the #!/usr/bin/env node shebang, bun run respects it by default and uses the system’s node executable. To force it to use Bun instead, pass --bun to bun run.
When you pass --bun, Bun creates a symlink to the locally-installed Bun executable named "node" in a temporary directory and adds it to your PATH for the duration of the script.
terminal
Global installs
Install packages globally withbun i -g <package>. By default, they go into a .bun/install/global/node_modules folder inside your home directory.
terminal