How I initialize my Bun projects
Bun has a bun init
command that helps you initialize a new project. However, afterwards I also do these:
Use
@tsconfig/bun
instead of providedtsconfig.json
. This provides a stricter TypeScript configuration and also reduces the need to maintain our own tsconfig file.bun add @tsconfig/bun --dev echo '{ "extends": "@tsconfig/bun/tsconfig.json" }' > tsconfig.json
Also install
@types/node
. Without it, sometimes TypeScript would emit type errors, saying that “Buffer is not assignable to Uint8Array”.bun add @types/node --dev
Pin the Bun version in mise-en-place config. This helps with reproducability when working with multiple projects and when deploying.
mise use bun@latest
Later, the correct version of Bun will be installed when you run
mise install
.