A modern, minimal template for starting TypeScript projects on Node.js with sensible defaults and a smooth developer experience.
- TypeScript 5 with strict mode and Node LTS (22) aligned config
- Fast iteration using
ts-node for development - Biome (formatter + linter) for consistent, high-quality code
- Environment variables via
dotenv - Dependency management with
pnpm
- Node.js 20 or 22+ (LTS recommended)
- pnpm 10+
- Clone and install dependencies:
git clone https://github.com/sajaddp/typescript-template.gitcd typescript-templatepnpm i
MY_SECRET="your-secret-value"
The app logs the value ofMY_SECRET to the console.
pnpm dev: Run the app withts-node fromsrc/index.ts.pnpm build: Compile TypeScript withtsc.pnpm format: Format codebase with Biome's formatter.pnpm lint: Run Biome in safe mode (formats and sorts imports).pnpm lint:unsafe: Run Biome with unsafe fixes (also removes unused imports).
Note: Afterpnpm build, JavaScript output is emitted alongside the.ts files by default. You can setoutDir intsconfig.json (e.g.,dist) and then runnode dist/index.js.
.├── src/│ └── index.ts # Entry point (example: reading an env variable)├── biome.json # Biome configuration for formatting and lint checks├── tsconfig.json # TypeScript configuration aligned with Node 22├── package.json # Scripts and dependencies├── .env # Local environment variables└── README.MD
- Target:
es2023 - Module/Resolution:
node16 - Enabled:
strict: true,esModuleInterop: true,resolveJsonModule: true
To emit compiled files into a separate directory, enableoutDir intsconfig.json.
- Missing env value: Ensure
.env exists andMY_SECRET is defined, then run withpnpm dev. - Where is the build output? Without
outDir,.js files are emitted next to.ts. Either runnode src/index.js or configureoutDir (e.g.,dist) and runnode dist/index.js.
Released under the MIT License.