A complete Node.js .gitignore
Starting a Node project means deciding what not to commit: dependencies, secrets, build artifacts, logs, and editor clutter. This builder generates a thorough .gitignore for Node, npm, and JavaScript projects, with each section toggleable so you only ship the patterns you actually need.
How it works
Git reads .gitignore from the repository root and applies each line as a pattern: a name matches files and folders anywhere below, a trailing slash matches directories only, and a leading slash anchors to the root. This builder assembles grouped sections — dependencies (node_modules/), environment files (.env, .env.local), build output (dist/, build/, .next/), logs (*.log, npm-debug.log*), coverage (coverage/, .nyc_output/), editor folders (.vscode/, .idea/), and OS files (.DS_Store, Thumbs.db). Toggling a section simply includes or omits its block in the live output.
Tips and example
Keep the lockfile (package-lock.json or yarn.lock) committed — it is not ignored here. A typical generated block includes:
# Dependencies
node_modules/
# Environment
.env
.env.local
.env.*.local
# Build output
dist/
build/
.next/
.turbo/
# Logs
*.log
npm-debug.log*
# OS files
.DS_Store
Thumbs.db
If you accidentally committed a file before adding it here, run git rm --cached <file> to stop tracking it while keeping it on disk.