Project Setup Best Practices
Standards for Node service repositories that onboard fast, build in CI, and deploy predictably.
Search across all documentation pages
Standards for Node service repositories that onboard fast, build in CI, and deploy predictably.
src/ for runtime code and a dedicated test location. Pick test/ or colocated *.test.ts, not both.apps/billing-api maps to one container image.tsconfig, ESLint, and Dockerfile discoverability matters..env.example, never secrets. Document every required variable with safe defaults.health (and optionally ready) routes from day one. Load balancers and orchestrators need them.tsconfig.json and tsconfig.build.json. Typecheck tests; emit only src/ to dist/.NodeNext module resolution on Node 24. Matches ESM import behavior in production.createApp() (or equivalent) from servers. Enables HTTP integration tests without binding ports.dev, build, start, test, typecheck. Same commands locally and in CI.start against compiled JS. Not tsx in containers.node:24.18.0-alpine). Align with engines in package.json.npm ci layer rebuilds only when deps change.NODE_ENV=production in runtime stage. Frameworks and log verbosity depend on it.packages/, deployables in apps/. Apps never import sibling apps directly.npm ci, env copy, npm run dev. Three steps to running server.npm test passing trivially..gitignore covers node_modules, dist, .env, coverage. Prevent accidental commits.Either works. test/ simplifies dist/ output; colocated tests improve locality. Pick one per org.
When two deployables share evolving contracts and you want atomic PRs. Not for a single API with copy-paste helpers.
Yes for containerized deploys. Serverless uses packaging config instead but same build/typecheck scripts apply.
Layout, scripts, ESLint, sample test, Docker, CI workflow, .env.example, and README - proven green on every tag.
Widen engines temporarily, pin CI matrix, migrate app-by-app, then tighten engine-strict.
No for container builds that compile in CI/Docker. Yes only for atypical git-deploy flows (avoid if possible).
Group by domain (routes/, services/) not by layer only. Depth grows with feature count, not upfront.
Yes: src/worker.ts, same scripts, separate Dockerfile or process command. Reuse packages/ for job payloads.
Each PR deploys one app from apps/* with path filters; document naming in platform runbooks.
npm ci, npm run typecheck, npm test, npm run build, Docker build (if used).
Stack versions: This page was written for Node.js 24.18.0 (Active LTS), npm 10+, TypeScript 5.6+, Express 5, Fastify 5, and NestJS 11.
Reviewed by Chris St. John·Last updated Jul 19, 2026