Intro
What is Bun?
Installation
Quickstart
TypeScript
Templating
bun init
bun create
Runtime
bun run
File types
TypeScript
JSX
Environment variables
Bun APIs
Web APIs
Node.js compatibility
Single-file executable
Plugins
Watch mode
Module resolution
Auto-install
bunfig.toml
Debugger
Framework APISOON
Package manager
bun install
bun add
bun remove
bun update
bun publish
bun outdated
bun link
bun pm
Global cache
Workspaces
Lifecycle scripts
Filter
Lockfile
Scopes and registries
Overrides and resolutions
Patch dependencies
.npmrc support
Bundler
Bun.build
HTML & static sites
CSS
Fullstack Dev Server
Hot reloading
Loaders
Plugins
Macros
vs esbuild
Test runner
bun test
Writing tests
Watch mode
Lifecycle hooks
Mocks
Snapshots
Dates and times
DOM testing
Code coverage
Package runner
bunx
API
HTTP server
HTTP client
WebSockets
Workers
Binary data
Streams
SQL
S3 Object Storage
File I/O
import.meta
SQLite
FileSystemRouter
TCP sockets
UDP sockets
Globals
$ Shell
Child processes
HTMLRewriter
Hashing
Console
Cookie
FFI
C Compiler
Testing
Utils
Node-API
Glob
DNS
Semver
Color
Transpiler
Project
Roadmap
Benchmarking
Contributing
Building Windows
Bindgen
License
Search the docs...
/
Intro
What is Bun?
Installation
Quickstart
TypeScript
Templating
bun init
bun create
Runtime
bun run
File types
TypeScript
JSX
Environment variables
Bun APIs
Web APIs
Node.js compatibility
Single-file executable
Plugins
Watch mode
Module resolution
Auto-install
bunfig.toml
Debugger
Framework APISOON
Package manager
bun install
bun add
bun remove
bun update
bun publish
bun outdated
bun link
bun pm
Global cache
Workspaces
Lifecycle scripts
Filter
Lockfile
Scopes and registries
Overrides and resolutions
Patch dependencies
.npmrc support
Bundler
Bun.build
HTML & static sites
CSS
Fullstack Dev Server
Hot reloading
Loaders
Plugins
Macros
vs esbuild
Test runner
bun test
Writing tests
Watch mode
Lifecycle hooks
Mocks
Snapshots
Dates and times
DOM testing
Code coverage
Package runner
bunx
API
HTTP server
HTTP client
WebSockets
Workers
Binary data
Streams
SQL
S3 Object Storage
File I/O
import.meta
SQLite
FileSystemRouter
TCP sockets
UDP sockets
Globals
$ Shell
Child processes
HTMLRewriter
Hashing
Console
Cookie
FFI
C Compiler
Testing
Utils
Node-API
Glob
DNS
Semver
Color
Transpiler
Project
Roadmap
Benchmarking
Contributing
Building Windows
Bindgen
License
bun pm
Thebun pm
command group provides a set of utilities for working with Bun's package manager.
To create a tarball of the current workspace:
bun pm pack
Options for thepack
command:
--dry-run
: Perform all tasks except writing the tarball to disk.--destination
: Specify the directory where the tarball will be saved.--filename
: Specify an exact file name for the tarball to be saved at.--ignore-scripts
: Skip running pre/postpack and prepare scripts.--gzip-level
: Set a custom compression level for gzip, ranging from 0 to 9 (default is 9).Note--filename
and--destination
cannot be used at the same time
To print the path to thebin
directory for the local project:
bun pm bin
/path/to/current/project/node_modules/.bin
To print the path to the globalbin
directory:
bun pm bin -g
<$HOME>/.bun/bin
To print a list of installed dependencies in the current project and their resolved versions, excluding their dependencies.
bun pm ls
/path/to/project node_modules (135)├── eslint@8.38.0├── react@18.2.0├── react-dom@18.2.0├── typescript@5.0.4└── zod@3.21.4
To print all installed dependencies, including nth-order dependencies.
bun pm ls --all
/path/to/project node_modules (135)├── @eslint-community/eslint-utils@4.4.0├── @eslint-community/regexpp@4.5.0├── @eslint/eslintrc@2.0.2├── @eslint/js@8.38.0├── @nodelib/fs.scandir@2.1.5├── @nodelib/fs.stat@2.0.5├── @nodelib/fs.walk@1.2.8├── acorn@8.8.2├── acorn-jsx@5.3.2├── ajv@6.12.6├── ansi-regex@5.0.1├── ...
Print your npm username. Requires you to be logged in (bunx npm login
) with credentials in eitherbunfig.toml
or.npmrc
:
bun pm whoami
To generate and print the hash of the current lockfile:
bun pmhash
To print the string used to hash the lockfile:
bun pm hash-string
To print the hash stored in the current lockfile:
bun pm hash-print
To print the path to Bun's global module cache:
bun pm cache
To clear Bun's global module cache:
bun pm cache rm
To migrate another package manager's lockfile without installing anything:
bun pm migrate
To print current untrusted dependencies with scripts:
bun pm untrusted
./node_modules/@biomejs/biome @1.8.3 » [postinstall]: node scripts/postinstall.jsThese dependencies had their lifecycle scripts blocked during install.
To run scripts for untrusted dependencies and add totrustedDependencies
:
bun pm trust<names>
Options for thetrust
command:
--all
: Trust all untrusted dependencies.To print the default trusted dependencies list:
bun pm default-trusted
see the current list on GitHubhere