pnpm .gitignore template
The pnpm template is three rules long, because the tool keeps a single content addressed store outside the project and hard links into it instead of copying files.
At a glance
- Category
- Build Tool
- Patterns in this template
- 3 rules
- Directories ignored
- 2 of the 3 rules end in a slash, so they match directories only
- Also needs an OS template
- Yes. This covers the package manager only.
- Typical companions
- JavaScript, TypeScript or Node.js, plus an OS template.
In detail
This template is short because of how the tool works. Instead of copying every package into each project, it keeps one content addressed store on the machine and creates hard links from the project into it. The node_modules directory still exists, but it is a structure of links rather than a full copy, which is why installs are fast and why disk usage does not multiply across projects.
That structure is still not something to commit. The links point into a store path in the home directory, so the tree is meaningless on any other machine, and the nested .pnpm directory inside it encodes the exact resolution graph. The rule is the same as for any other package manager even though the mechanism underneath differs.
.pnpm-store is the store itself, ignored here for the case where it has been configured to live inside the project rather than in the home directory. That configuration exists for continuous integration setups that want the store on a cached volume alongside the checkout.
pnpm-debug.log is written when a command fails, holding the full context of the failed operation. As with every other package manager's crash log, it is useful once and stale immediately. It records the resolved dependency graph at the moment of failure along with the command line and the environment, which is worth reading before you delete it.
The absence worth noting is pnpm-lock.yaml. It is not ignored by anything here, and that is deliberate: the lockfile pins the exact versions and integrity hashes for the whole tree, and it must be committed for the strict, non flat node_modules layout to be reproducible.
Examples
node_modules/
.pnpm-store/
pnpm-debug.log*3 lines exactly as the tool writes them, before any common additions you tick.
Things that catch people out
- The lockfile is not ignored and should not be. If you copied a rule for it from another template, remove it, because the strict layout depends on the lockfile being present.
- Workspace projects create a node_modules directory in every package. The unanchored rule covers all of them, which is what you want in a monorepo.
- This template does not cover .npmrc, and pnpm reads that file too, including any registry auth token in it.
Try it: .gitignore Generator
Pick one or more templates, tick the common additions you want, and copy or download the combined .gitignore.
.gitignore Generator
LOCAL · Browser-OnlyGenerate comprehensive .gitignore files by combining templates for languages, frameworks, IDEs, and operating systems
Language
Framework
IDE
OS
Build Tool
Infrastructure
Common Additions
Preview
Select templates or common additions to generate a .gitignore file.
Related .gitignore templates
All .gitignore templates →npm .gitignore template
This template ignores package-lock.json, which contradicts the current advice to commit the lockfile. Here is what the rest of it covers and what to change.
Yarn .gitignore template
The Yarn template ignores the .yarn directory's contents while negating five subdirectories, because which ones you keep depends on the install mode you use.
Node.js .gitignore template
The longest JavaScript oriented template: dependency directories, every package manager's debug log, bundler caches, env files and Yarn Plug'n'Play state.
Docker .gitignore template
A small template with two rules worth questioning: it ignores .dockerignore, and it ignores every compose file except two, which suits few projects.
Terraform .gitignore template
State files contain secrets in plain text and must never be committed. This template covers that, and also ignores the lock file, which should be tracked.
Vagrant .gitignore template
Two rules worth understanding: the .vagrant directory holds machine identifiers and a generated private key, and box files are multi gigabyte disk images.
Tools for this
- .gitignore Generator Generate .gitignore files for any project - 50+ templates for languages, frameworks, IDEs, and OS
- package.json Generator Generate package.json files with a form-based builder - 8 project presets, all fields supported