Generate a complete .gitignore for Node.js projects. Covers node_modules, env files, build output, logs, and package manager caches.
# 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
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.
| 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 |
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.
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.