DevBento logoDevBento
Tools/.gitignore Generator/Gitignore for Node.js

Gitignore for Node.js

Generate a complete .gitignore for Node.js projects. Covers node_modules, env files, build output, logs, and package manager caches.

Languages & Runtimes
Editors & IDEs
Operating Systems
Frameworks & Tools
.gitignore1 template · 28 rules
# Node.js
node_modules/
dist/
build/
.npm
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
.pnp.*
.pnpm-store/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
.env
.env.*
!.env.example
coverage/
.cache/
.parcel-cache/
.vite/
.eslintcache
*.tgz
*.tsbuildinfo
# Generated with devbento.dev/tools/gitignore-generator
Send to:
Related Tools
.git.gitignore Generator
Generate .gitignore files for any project stack. Select from 30+ templates for languages, editors, and operating systems, then download or copy.
+/-Diff Checker
Compare two blocks of text side by side or inline with character-level highlighting. Find additions, removals, and changes instantly in your browser.

Gitignore for Node.js

This example generates a production ready .gitignore for any Node.js project: backend APIs, CLIs, and full stack apps. It covers dependencies, secrets, build output, logs, coverage, and caches for npm, Yarn, and pnpm in one template.

What the Template Ignores

Pattern Reason
node_modules/ Installed packages, reconstructable from package.json
.env, .env.* Secrets and per machine config
!.env.example Exception so the variable template stays committed
dist/, build/ Compiled output from tsc, Vite, or esbuild
npm-debug.log*, yarn-debug.log*, yarn-error.log*, pnpm-debug.log*, lerna-debug.log* Package manager debug logs
coverage/ Test coverage reports from Jest, Vitest, or nyc
.cache/, .parcel-cache/, .vite/, .eslintcache, *.tsbuildinfo Tool caches that speed up local runs
*.tgz Output of npm pack
report.[0-9]* JSON Node diagnostic reports

How to Use

  1. The tool opens with the Node.js template preselected
  2. Add OS or editor templates such as macOS or VS Code with the multi select
  3. Click Generate, copy the result, and save it as .gitignore in your project root
  4. Commit it before your first real code so junk never enters history

Combining Templates

Real projects need more than one template. A typical Node API also selects macOS or Windows for OS files and VS Code or JetBrains for editor files. The generator merges them and removes duplicate lines, so the output stays clean.

Cleaning an Existing Repo

If node_modules or .env files are already tracked, ignoring them is not enough. Untrack with git rm -r –cached node_modules and git rm –cached .env, then commit the .gitignore. For secrets that were pushed, rotate them: removing from history requires filter-repo and every key in the file must be treated as compromised.

For related workflows, compare ignore files with the Diff Checker or generate the full Gitignore Generator with extra templates.

🔒

Nothing you paste leaves this tab. Every tool runs entirely in your browser — no upload, no server, no account.

© 2026 devbento.dev · built local-firstAll ToolsChangelog