Skip to content

threeal/nodejs-starter

Repository files navigation

Node.js Starter

A minimal template for building a Node.js library in TypeScript with ESM support and an optional CLI. Ships pre-configured with formatting, linting, 100% test coverage enforcement, pre-commit hooks, and CI.

Getting Started

Create a new repository from this template on GitHub using this link, or clone it locally and point it at your own remote.

Setup

Install pnpm, then install dependencies:

pnpm install

Install Lefthook, then register the pre-commit hook:

lefthook install

Customizing

Replace or extend the template files to fit your project:

  • src/cli/ — Replace or remove the placeholder CLI commands. Remove this folder and the bin entry in package.json if your project doesn't need a CLI.
  • src/fibonacci.ts — Replace with your own library logic.
  • src/index.ts — Update the public API exports to match your library.
  • CLAUDE.md — Replace with guidance specific to your project.
  • LICENSE — Replace with your preferred license, or keep the Unlicense.
  • package.json — Update the project name, description, version, and other metadata.
  • README.md — Replace with a description of your project.

Development

Write code in src/. Test files live alongside source as *.test.ts. Run the test suite with:

pnpm vitest run

The project enforces 100% code coverage on every run.

Before committing, run the pre-commit hook to install dependencies, type-check, and fix formatting and lint:

lefthook run pre-commit

If any file changes during the run, re-stage the changed files and retry. The hook also runs automatically on each git commit — if it fails, fix the reported issues, re-stage, and commit again.

After committing, push to main or open a pull request from another branch — CI will run the pre-commit hook across all files, the full test suite, and pnpm pack.

Releasing

Update the version in package.json, push a version tag, and create a GitHub Release. To publish to the npm registry, run:

pnpm publish

Framework-Specific Templates

For a more opinionated starting point in a specific framework:

About

Minimal template for building a Node.js library and CLI in TypeScript

Topics

Resources

License

Stars

Watchers

Forks

Contributors