πŸ“‹ Cheat Sheets
Β· 1 min read

The .gitignore for Every Node.js Project β€” Complete & Copy-Ready


Here’s the .gitignore that covers Node.js, TypeScript, Next.js, and most fullstack setups.

The .gitignore

# Dependencies
node_modules/
.pnp
.pnp.js

# Build output
dist/
build/
out/
.next/
.nuxt/
.output/
.vercel/
.netlify/

# Environment
.env
.env.local
.env.development.local
.env.test.local
.env.production.local
.env*.local

# IDE
.vscode/settings.json
.idea/
*.swp
*.swo
*~
.DS_Store
Thumbs.db

# Testing
coverage/
.nyc_output/

# Debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# TypeScript
*.tsbuildinfo

# Misc
*.pem
.turbo/
.cache/
.temp/
.tmp/

What’s covered

  • Dependencies β€” node_modules (obviously), PnP files for Yarn
  • Build artifacts β€” dist, build, .next, .nuxt, .output
  • Environment files β€” all .env variants (never commit secrets)
  • IDE files β€” VS Code settings, JetBrains, vim swap files
  • OS files β€” .DS_Store (macOS), Thumbs.db (Windows)
  • Test coverage β€” coverage reports don’t belong in git
  • Debug logs β€” npm/yarn/pnpm debug logs
  • TypeScript β€” incremental build info files
  • Turborepo β€” .turbo cache directory

Already committed files you want to ignore?

# Remove from git tracking (keeps the file locally)
git rm --cached .env
git rm --cached -r node_modules/
git rm --cached .DS_Store

# Then commit
git add .gitignore
git commit -m "Add .gitignore, remove tracked files"

Want to keep .vscode but only share extensions?

Replace the .vscode/settings.json line with:

.vscode/*
!.vscode/extensions.json

This shares recommended extensions with your team but keeps personal settings private.

Copy the file, drop it in your project root, done.

πŸ“˜