~/.npm is npm's download cache, mostly in the _cacache folder, with npx packages and logs beside it. It is safe to clear. Run npm cache clean --force and npm fetches packages again on the next install. Your projects, package.json files and node_modules folders are not affected.
- Path
~/.npm- What it is
- npm's cache of downloaded packages (_cacache), plus npx packages and logs
- Typical size
- From hundreds of megabytes to several gigabytes, depending on how many projects you install
- Made by
- npm
- Safe to delete?
- Safe to clear
- Comes back?
- Yes, npm re-downloads packages on the next install
What is in this folder?
npm stores every tarball and metadata response it downloads in ~/.npm/_cacache so repeat installs and offline installs are fast. The same folder holds _npx, where one-off npx packages are cached, and _logs.
The npm documentation notes that the cache is self-healing: corrupted entries are refetched automatically, and clearing it should only be necessary to reclaim disk space.
Is it safe to delete?
Yes. Nothing in the cache is unique. Everything in it came from the npm registry and can be fetched again. The only cost is bandwidth and time on the next install.
The one case to avoid is working offline, where the cache may be the only copy of packages you need to install.
How do I clear it by hand?
- Stop any running
npm installor dev server that is installing packages. - Run the command below. npm requires
--forceto clear the cache. - Optionally check the state of what remains with
npm cache verify.
npm cache clean --forceThis clears the cache, not node_modules. Project folders keep working.
How do I stop it growing?
npm does not cap the cache. Running npm cache clean --force every few months keeps it small.
How Clean House handles it
Clean House recognizes ~/.npm/_cacache as the npm cache, made by npm, and marks it as something that downloads again. The Why card says what happens if it goes, and the files go to the Trash before anything is permanent.