Skip to content

mkvlrn/template-node

Repository files navigation

template-node

build template mise license

A sane, opinionated template for esm node projects written in typescript that doesn't rely on transpilation - typescript is ran directly by node.

Note

This template provides a mise configuration to make it easy to keep node and pnpm versions in sync.

Uses, among other tools/packages:

  • pnpm as package manager for node dependencies
  • biome for code linting and formatting
  • lefthook for git hooks
  • commitlint for commit message linting
  • vitest for testing

requirements and dependencies

If you use mise and run mise install in the project root, you'll have the correct node and pnpm versions installed.

This is by far the easiest way to keep your environment consistent across different machines and team members, no matter the frequency of version updates. I'm not affiliated with mise but I wholeheartedly recommend it, so check it here: https://mise.jdx.dev.

If not using mise, make sure you have:

  • node 24+ installed (v24.14.1 used)
  • pnpm 10+ installed (v10.33.0 used)

Then, install dependencies with:

pnpm install

Note

Git hooks are in place to make sure both the tooling managed by mise and the project dependencies are synced with each checkout and merge.

subpath imports

Subpath imports (#/) are used instead of relative paths, mapped in both package.json and tsconfig.json.

Example:

import { add } from "#/math/basic"; // this points to ./src/math/basic.ts

running

pnpm dev

Runs the project in watch mode.

pnpm start

Runs the project.

pnpm test

Runs tests.

pnpm biome-fix

Runs biome in fix mode to lint and format the project.

pnpm typecheck

Runs type checking using tsc.

ci

This repository uses GitHub Actions for CI. The workflow is defined in .github/workflows/checks.yml.

It automates:

  • Linting & Formatting: Running Biome.
  • Type Checking: Running TypeScript type checking.
  • Testing: Running Vitest with code coverage (generated by Istanbul).

vscode

You might want to install the recommended extensions in vscode. Search for @recommended in the extensions tab, they'll show up as "workspace recommendations".

If you have been using eslint and prettier and their extensions, you might want to disable eslint entirely and keep prettier as the formatter only for certain types of files.

This is done by the .vscode/settings.json file.

Debug configuration is also included for running the source directly with node.

license

MIT

About

A template for esm Node.js projects using typescript

Topics

Resources

License

Stars

Watchers

Forks

Contributors