Developer Tools
•
5 min read
•
September 2026
How to Clean npm, Yarn & pnpm Cache on macOS
Purge global package manager caches, sweep dead node_modules directories, and free up 20GB+ of developer SSD storage.
Where JavaScript Developers Lose 30GB+
Modern full-stack JavaScript developers accumulate immense package manager caches across npm, Yarn, and pnpm:
~/.npm(Global npm tarball cache)~/Library/Caches/Yarn(Yarn v1 & Berry cache)~/Library/pnpm/store(pnpm hard-link store)- Hundreds of forgotten
node_modulesfolders in abandoned client projects.
Terminal Commands to Wipe Package Caches
# Clear global npm cache
npm cache clean --force
# Clear Yarn cache
yarn cache clean
# Prune unreferenced pnpm packages
pnpm store prune
# Find all node_modules folders taking up storage
find ~/Projects -name "node_modules" -type d -prune -exec du -sh {} + 2>/dev/null
npm cache clean --force
# Clear Yarn cache
yarn cache clean
# Prune unreferenced pnpm packages
pnpm store prune
# Find all node_modules folders taking up storage
find ~/Projects -name "node_modules" -type d -prune -exec du -sh {} + 2>/dev/null
⚡ Developer Efficiency
Sweep Dead Dependencies with XrayMac
XrayMac scans your APFS disk to pinpoint abandoned JavaScript dependency trees and package manager caches, giving you instant visibility into multi-gigabyte black holes.
Frequently Asked Questions
Will npm cache clean delete my node_modules?
No. npm cache clean only purges the global download archive in ~/.npm. Local project dependencies in node_modules are untouched.
XrayMac Engineering Team
Pure Swift 6 & APFS storage diagnostics for macOS Sonoma & Sequoia.