Skip to main content

Command Palette

Search for a command to run...

Bun: A fast all in one toolkit for JS and TS.

Published
2 min read
D

A 19y/o self-learned ethical hacker, mainly interested in bug hunting, malware analysis, and digital forensics. Currently expertise in SEO, OSINT, ethical hacking, WordPress, Shopify, front-end web.

It is an all-in-one toolkit for developing modern JavaScript/TypeScript applications.

It has -

  1. Bun Runtime - a fast JavaScript runtime designed as a drop in replacement for node.js
    Try - bun run

  2. Bun Package Manager - install packages almost 30x faster than npm using with global cache and workspace.
    Try - bun install

  3. Bun Test Runner - fast, built-in, Jest-compatible test runner with TypeScript support, lifecycle hooks, mocking, and watch mode.
    Try - bun test

  4. Bun Bundler - Bundle Typescript, JSX, React and CSS for browsers and servers.
    Try - bun build

bun run start                 # run the `start` script
bun install <pkg>             # install a package
bun build ./index.tsx         # bundle a project for browsers
bun test                      # run tests
bunx cowsay 'Hello, world!'   # execute a package

Bun Runtime

Execute JavaScript/TypeScript files, package.json scripts, and executable packages with Bun’s fast runtime.

  • Run a file - Use bun run to execute a source file like bun run index.js. (we can skip the run keyword if we want)

  • Run a file in watch mode - bun --watch run index.tsx

  • Run a package.json script - bun [bun flags] run <script> [script flags] like bun run dev

  • To see a list of available scripts, run bun run without any arguments.

  • It’s common for package.json scripts to reference locally-installed CLIs like vite or next. However, you can override this behavior with the --bun flag.

Watch Mode - Automatic reloading in Bun with —watch and —hot modes