Bun v1.0.17 fixes 15 bugs (addressing 152 👍 reactions). bun install
postinstall scripts run for top 500 packages, bunx supabase
starts 30x faster than npx supabase
, bunx esbuild
starts 50x faster than npx esbuild
and bugfixes to bun install
Bun is an incredibly fast JavaScript runtime, bundler, transpiler, and package manager — all in one. In case you missed it, here are some of the recent changes to Bun:
v1.0.13
- Fixes 6 bugs (addressing 317 👍 reactions). 'http2' module & gRPC.js work now. Vite 5 & Rollup 4 work. Implements process.report.getReport(), improves support for ES5 'with' statements, fixes a regression in bun install, fixes a crash when printing exceptions, fixes a Bun.spawn bug, and fixes a peer dependencies bugv1.0.14
-Bun.Glob
, a fast API for matching files and strings using glob patterns. It also fixes a race condition when extracting dependencies duringbun install
, improves TypeScript module resolution innode_modules
, and makes error messages easier to read.v1.0.15
- Fixes 23 bugs (addressing 117 👍 reactions),tsc
starts 2x faster. StableWebSocket
client, syntax-highlighted errors, cleaner stack traces, add custom test matchers withexpect.extend()
+ additional expect matchers.v1.0.16
- Fixes 49 bugs (addressing 38 👍 reactions). Concurrent IO for Bun.file & Bun.write gets 3x faster and now supports Google Cloud Run & Vercel, Bun.write auto-creates the parent directory if it doesn't exist,expect.extend
inside of preload works,napi_create_object
gets 2.5x faster, bugfix for module resolution impacting Astro v4 and p-limit, console.log bugfixes
To install Bun:
curl -fsSL https://bun.sh/install | bash
npm install -g bun
brew tap oven-sh/bun
brew install bun
docker pull oven/bun
docker run --rm --init --ulimit memlock=-1:-1 oven/bun
To upgrade Bun:
bun upgrade
bun install now runs lifecycle scripts for the top 500 npm packages
In this release, we've added the top 500 most-downloaded npm packages in a default allowlist to run lifecycle scripts during bun install
. This means that bun install
will now run preinstall
, install
, and postinstall
scripts for the top 500 npm packages which have them defined.
This addresses many issues with bun install
:
Thanks to @dylan-conway and @paperclover for implementing this.
Lifecycle scripts now run in parallel
As part of the above work, we also made lifecycle scripts run in parallel, which reduces the impact of lifecycle scripts on installation time.
Configuring concurency
You can configure the maximum number of concurrent lifecycle scripts that run at once either by
bunfig.toml
:
# Only run 5 in parallel at max
install.concurrentScripts = 5
CLI argument:
bun install --concurrent-scripts=5
Environment variable:
GOMAXPROCS=2 bun install
Note: it is $GOMAXPROCS
because we use that elsewhere and it's one less environment variable for us to make up a name for (it's what Go uses, but Bun doesn't use Go).
Error message improvement in bun install
When a permissions error occurs, bun install now shows a more helpful error message. Instead of just "Unexpected", it now provides more information when it can.
Thanks to @paperclover for implementing this.
Fixed: Semver pre-release sorting bug
A crash that could occur when sorting many pre-release versions of specific input simultaneously has been fixed. This bug was fixed by @dylan-conway. This bug could be reproduced when installing 4 year old versions of Gatsby.
Fixed: lifecycle script dependency install order
A bug where bun install
would install lifecycle scripts without first ensuring all dependent lifecycle scripts were installed has been fixed. This bug was fixed by @dylan-conway.
bunx supabase
starts 30x faster than npx supabase
Since bun install
now enables lifecycle scripts for popular packages by default, bunx supabase
now works.
On Linux x64, bun x supabase
starts 30x faster than npx supabase
:
Benchmark 1: bun x supabase
Time (mean ± σ): 10.5 ms ± 1.0 ms [User: 8.0 ms, System: 5.5 ms]
Range (min … max): 8.5 ms … 13.1 ms 248 runs
Benchmark 2: npx supabase
Time (mean ± σ): 325.2 ms ± 30.6 ms [User: 272.6 ms, System: 117.9 ms]
Range (min … max): 291.0 ms … 389.9 ms 10 runs
Summary
bun x supabase ran
30.90 ± 4.17 times faster than npx supabase
bunx esbuild
starts 50x faster than npx esbuild
Now that bun install
enables lifecycle scripts for popular packages by default, bunx esbuild
now starts roughly 50x faster than npx esbuild
:
Benchmark 1: bun x esbuild --help
Time (mean ± σ): 3.5 ms ± 0.3 ms [User: 1.8 ms, System: 1.6 ms]
Range (min … max): 2.8 ms … 4.3 ms 827 runs
Benchmark 2: npx esbuild --help
Time (mean ± σ): 295.7 ms ± 23.8 ms [User: 270.0 ms, System: 100.6 ms]
Range (min … max): 259.6 ms … 339.6 ms 10 runs
Summary
bun x esbuild --help ran
83.84 ± 9.31 times faster than npx esbuild --help
-h
is now an alias of --help
-h
is now an alias of --help
for all commands. Thanks to @hustLer2k for implementing this.
$ bun -h
Bun is a fast JavaScript runtime, package manager, bundler, and test runner. (1.0.16 (a2f595d3))
Usage: bun <command> [...flags] [...args]
Commands:
run ./my-script.ts Execute a file with Bun
lint Run a package.json script
test Run unit tests with Bun
x vite Execute a package binary (CLI), installing if needed (bunx)
repl Start a REPL session with Bun
install Install dependencies for a package.json (bun i)
add svelte Add a dependency to package.json (bun a)
remove babel-core Remove a dependency from package.json (bun rm)
update lodash Update outdated dependencies
link [<package>] Register or link a local npm package
unlink Unregister a local npm package
pm <subcommand> Additional package management utilities
build ./a.ts ./b.jsx Bundle TypeScript & JavaScript into a single file
init Start an empty Bun project from a blank template
create Create a new project from a template (bun c)
upgrade Upgrade to latest version of Bun.
<command> --help Print help text for command.
Flags:
--watch Automatically restart the process on file change
--hot Enable auto reload in the Bun runtime, test runner, or bundler
--smol Use less memory, but run garbage collection more often
-r, --preload Import a module before other modules are loaded
--inspect Activate Bun's debugger
--inspect-wait Activate Bun's debugger, wait for a connection before executing
--inspect-brk Activate Bun's debugger, set breakpoint on first line of code and wait
--if-present Exit without an error if the entrypoint does not exist
--no-install Disable auto install in the Bun runtime
--install Configure auto-install behavior. One of "auto" (default, auto-installs when no node_modules), "fallback" (missing packages only), "force" (always).
-i Auto-install dependencies during execution. Equivalent to --install=fallback.
-e, --eval Evaluate argument as a script
--prefer-offline Skip staleness checks for packages in the Bun runtime and resolve from disk
--prefer-latest Use the latest matching versions of packages in the Bun runtime, always checking npm
-p, --port Set the default port for Bun.serve
-b, --bun Force a script or package to use Bun's runtime instead of Node.js (via symlinking node)
--silent Don't print the script command
-v, --version Print version and exit
--revision Print version with revision and exit
--env-file Load environment variables from the specified file(s)
--cwd Absolute path to resolve files & entry points from. This just changes the process' cwd.
-c, --config Specify path to Bun config file. Default $cwd/bunfig.toml
-h, --help Display this menu and exit
(more flags in bun install --help, bun test --help, and bun build --help)
Learn more about Bun: https://bun.sh/docs
Join our Discord community: https://bun.sh/discord
Fixed: encoding argument in fs.createReadStream
A bug where the encoding
argument in fs.createReadStream
was not handled correctly has been fixed. This bug was fixed by @hustLer2k.