A baseline Node.js + TypeScript template for starting new projects, pre-wired with linting/formatting, testing, git hooks, versioning, and CI.
- TypeScript (
typescript@^6) — strict config, compiled withtsc --noEmitfor type-checking and bundled withtsup. (Note: TypeScript 7's native Go compiler is much faster but doesn't ship a Compiler API yet, whichtsup's declaration-file generation depends on. Revisit upgrading once the ecosystem supports TS 7's new API — see the@typescript/typescript6compat shim in the meantime.) - tsup — bundles
src/into dual ESM/CJS output with.d.tsfiles indist/. - tsx — runs/watches TypeScript directly during development and testing, no separate compile step.
node:test+node:assert— built-in, zero-dependency test runner.- Biome — single tool for linting and formatting (replaces ESLint + Prettier).
- Husky + commitlint —
enforces Conventional Commits via a
commit-msghook. - lint-staged — runs Biome on
staged files via a
pre-commithook. - Changesets — manages versioning and changelogs from conventional-commit-style PRs.
- GitHub Actions — CI runs lint, typecheck, test, and build on every push
and pull request to
main; an optional release workflow opens/updates a "Version Packages" PR and publishes to npm when merged (requires anNPM_TOKENrepository secret).
pnpm install
pnpm dev # watch src/index.ts with tsx| Script | Description |
|---|---|
pnpm dev |
Run src/index.ts with tsx, watching for changes |
pnpm build |
Bundle src/ to dist/ (ESM + CJS + .d.ts) with tsup |
pnpm test |
Run tests with Node's built-in test runner |
pnpm test:coverage |
Run tests with coverage enabled |
pnpm lint |
Check formatting/lint issues with Biome |
pnpm lint:fix |
Fix formatting/lint issues with Biome |
pnpm format |
Format files with Biome |
pnpm typecheck |
Type-check the project with tsc --noEmit |
pnpm changeset |
Record a changeset describing your change |
pnpm release |
Publish packages with pending changesets |
Commits are linted with commitlint against the
Conventional Commits spec (e.g.
feat: add parser, fix: handle empty input, chore: bump deps). The
commit-msg git hook (via Husky) will reject non-conforming commit messages.
- Run
pnpm changesetand describe your change (patch/minor/major + summary). - Commit the generated file under
.changeset/along with your change. - On merge to
main, the release workflow opens or updates a "Version Packages" PR; merging that PR publishes the new version to npm (requires theNPM_TOKENsecret to be configured on the repository).
The fastest way, using the GitHub CLI (creates a new repo from this template and clones it in one command):
gh repo create my-new-project --template HDv2b/node-base --public --clone
cd my-new-project
pnpm installAlternatively, use GitHub's "Use this template" button on HDv2b/node-base, or clone it and re-init git:
git clone https://github.com/HDv2b/node-base.git my-new-project
cd my-new-project
rm -rf .git
git initThen update package.json (name, description, author, repository) and
replace the contents of src/index.ts.