Bun
Bun is a fast JavaScript runtime, package manager, bundler and test runner
Links, Courses and Tutorials about Bun.
Terminal
npm install -g bun
After installing Bun, you have access to all the great features it provides.
Templating
To scaffold a new project (similar to
npm init
), run:Terminal
bun init
Runtime
To run any Javascript or Typescript file, run:
Terminal
bun run filename.ts
The great thing about bun in particular is that it runs every Typescript file - no questions asked. You can even mix CommonJS (
require
) with ES Modules (import
) in the same file!Packages
To install, update or remove any npm packages with Bun, run:
Terminal
bun install package-name
Installing packages with bun is significantly faster than with
npm
.Likewise,
bun
also has its own version of npx
, but 100x faster:Terminal
bunx tailwindcss init
Bundling
To bundle your Typescript project into a bundled javascript file, run:
Terminal
bun build ./entrypoint.tsx --outdir ./build
Testing
Testing is also fairly easy with bun. First, create a test file:
number.test.ts
import { expect, test } from 'bun:test'test('2 + 2', () => { expect(2 + 2).toBe(4)})
Then, run all
*.test.ts
files using:Terminal
bun test