Bun is an all-in-one JavaScript runtime, bundler, transpiler, and package manager, designed for extreme speed and a streamlined developer experience. It is built on Apple's WebKit engine's JavaScriptCore and written in Zig. As of version 1.3.12, Bun offers a highly performant alternative to Node.js, providing native support for TypeScript, JSX, and ES modules out of the box. The project maintains a rapid release cadence with frequent patch and minor versions, often weekly, addressing bugs and introducing new features. Its key differentiators include significantly faster startup times, execution speed, and comprehensive tooling built into a single executable, aiming to replace a multitude of separate tools like Node.js, npm/yarn/pnpm, webpack, Babel, and esbuild. Bun is currently stable for production use but continues to evolve rapidly, adding new features and improving compatibility.
npm install bunVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a simple HTTP server using Bun's built-in `Bun.serve` API, handling basic routing and errors. It uses web-standard `Request` and `Response` objects and shows type-safety with TypeScript, which Bun supports natively.
Always pin exact Bun versions in CI/CD environments. Regularly test applications against new Bun versions and consult the official Bun release notes and migration guides.
Use `bun install --frozen-lockfile` in CI to ensure consistent builds. If issues persist, try `bun install --force` or manually clear `node_modules` and `bun.lockb`. Check Bun's documentation on package resolution for advanced configurations like `"trustedDependencies"`.
Thoroughly test existing Node.js applications when migrating to Bun. Consult Bun's compatibility tables in the documentation for known differences. Consider polyfills or alternative approaches for problematic Node.js APIs.
Ensure `package.json` correctly defines `"main"`, `"module"`, and `"exports"` fields. For TypeScript, verify `tsconfig.json`'s `"paths"` and `"baseUrl"` are compatible with Bun's resolver. Use explicit file extensions in imports where ambiguity might occur.
If installed via `curl | bash`, the installer attempts to add Bun to your shell's PATH. Restart your terminal or source your shell configuration file (`~/.bashrc`, `~/.zshrc`). If installed via npm (`npm install -g bun`), ensure your npm global bin directory is in your PATH. On Windows, use `powershell -c "irm bun.sh/install.ps1|iex"` and restart PowerShell.
Verify that `my-local-module` is correctly declared in your `package.json` dependencies or that its path is correctly specified in `tsconfig.json`'s `paths` and `baseUrl`. Ensure file extensions are consistent (e.g., if it's a `.ts` file, use `.ts` or ensure your `tsconfig.json` allows omitting it). Use `bun install` to ensure all dependencies are resolved.
Refactor the code to use ES module `import` statements. If you explicitly need to `require` a CommonJS module from an ESM context, Bun (like Node.js) allows `createRequire` from `node:module`: `import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);`Refactor recursive functions to be iterative where possible. For extremely deep recursion that cannot be easily converted, consider increasing the stack size if Bun provides a flag (check `bun --help`) or process large data in chunks to avoid deep stack usage.
No dependency data recorded yet.