React .gitignore Template

The full, current React .gitignore template — copy it as-is, or head to the .gitignore Generator to merge it with other stacks into one file.

Template

# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*

What each entry does

Why every line in this template is excluded, not just what it matches.

Entry Why it's excluded
/node_modules Installed npm/yarn/pnpm packages — fully reproducible from package.json and the lockfile, and can run into the tens of thousands of files.
/.pnp Files matching /.pnp — a generated or machine-specific file type for this stack, safe to regenerate rather than track.
.pnp.js Files matching .pnp.js — a generated or machine-specific file type for this stack, safe to regenerate rather than track.
/coverage Test-coverage report output — regenerated by the test runner, not something to diff in git.
/build Compiled/bundled output directory produced by the build tool — derived entirely from source, not source itself.
.DS_Store macOS Finder's per-folder metadata file (icon positions, view settings) — pure OS clutter with no project value.
.env.local A per-developer override of environment variables, not meant to be shared — same secret risk as .env.
.env.development.local Files matching .env.development.local — a generated or machine-specific file type for this stack, safe to regenerate rather than track.
.env.test.local Files matching .env.test.local — a generated or machine-specific file type for this stack, safe to regenerate rather than track.
.env.production.local Files matching .env.production.local — a generated or machine-specific file type for this stack, safe to regenerate rather than track.
npm-debug.log* Files matching npm-debug.log* — a generated or machine-specific file type for this stack, safe to regenerate rather than track.
yarn-debug.log* Files matching yarn-debug.log* — a generated or machine-specific file type for this stack, safe to regenerate rather than track.
yarn-error.log* Files matching yarn-error.log* — a generated or machine-specific file type for this stack, safe to regenerate rather than track.