Every Node.js project needs a .gitignore file. Without one, you'll end up committing node_modules (thousands of files), environment variables with API keys, build artifacts, and editor configuration files that don't belong in version control.
This template uses the official GitHub Node.js gitignore rules and adds commonly needed rules for VS Code, macOS, Windows, and Linux. It covers npm, yarn, and pnpm workflows out of the box.
How to Use
1. Review the pre-selected templates below (Node.js + VS Code + OS files)
2. Add or remove templates to match your project
3. Click "Copy" or "Download" to get the file
4. Place it in your project's root directory before your first commit
Frequently Asked Questions
Should I commit node_modules?
No. The node_modules directory can contain hundreds of megabytes of files and thousands of packages. It should always be in .gitignore. Use 'npm install' or 'yarn install' to recreate it from package.json and the lock file.
Should I commit package-lock.json or yarn.lock?
Yes. Lock files ensure everyone on your team gets the exact same dependency versions. Always commit your lock file (package-lock.json, yarn.lock, or pnpm-lock.yaml) but not node_modules itself.
Should I ignore .env files?
Yes. Environment files (.env, .env.local) often contain API keys, database credentials, and other secrets. Add .env* to your .gitignore. Use .env.example (committed) to document which variables are needed.