How to find and delete node_modules folders on Mac
It’s safe to delete node_modules on a Mac in your own projects you’re not working on: the folder holds only downloaded packages, and one install command brings it back when you return. Each JavaScript project keeps its own copy of every package it uses, so a few dozen old projects often take tens of gigabytes. This guide shows how to find every node_modules folder with its size, delete them one by one or all at once, and get them back.

- Open MacWashing and choose System Junk in the sidebar.
- Click Start Scan.
- Look through what it found and click Clean. Anything debatable stays unchecked.
Free trial · macOS 14 or later
Is it safe to delete node_modules?
Yes, in your own projects. node_modules holds only packages downloaded from the internet. Your code, package.json and the lock file (package-lock.json, yarn.lock or pnpm-lock.yaml) are next to it and stay. The project won’t run until you install the packages again.
Leave alone the global folders /usr/local/lib/node_modules and /opt/homebrew/lib/node_modules: they hold your globally installed tools and npm itself. Some apps also ship a node_modules folder they need to run.
How to find all node_modules folders and their size
This Terminal command lists every node_modules folder in your projects with its size, the biggest last. Replace ~/Projects with the folder where you keep your code:
find ~/Projects -name node_modules -type d -prune -exec du -sh {} + | sort -h
-prune stops find from looking inside each folder it found, so the packages’ own nested node_modules aren’t listed and counted twice. To see the node_modules size of one project, run this in its folder:
du -sh node_modulesHow to delete node_modules in one project
- In Finder, open the project folder.
- Select the
node_modulesfolder and choose File › Move to Trash (Command-Delete).

- Empty the Trash to get the space back.
In Terminal it’s faster for big folders. This command, run in the project folder, deletes its node_modules right away, past the Trash. The rest of the project stays:
rm -rf node_modulesDelete many node_modules folders with npkill
npkill is a free open-source tool that finds node_modules folders and deletes the ones you pick. It needs Node.js 14 or later. Run it with npx, without installing it for good:
npx npkill -d ~/Projects- Wait while npkill scans the folder. Each
node_modulesappears with its size and the date its project last changed. - Move through the list with the arrow keys and press Space to delete the highlighted folder.
- Press Q to quit.
npkill marks with a warning sign the folders that installed apps may need to run. Leave those alone. Add -s size to the command to see the biggest folders first.
To delete every node_modules in a folder at once, use find again. This command deletes all of them in ~/Projects past the Trash and keeps everything else. Run the listing command above first to see what goes:
find ~/Projects -name node_modules -type d -prune -exec rm -rf {} +How to get node_modules back
In the project folder, run the install command of the package manager the project uses. For npm with a package-lock.json, this installs exactly the versions in the lock file:
npm ci- Without a lock file:
npm install - Projects with
yarn.lock:yarn install - Projects with
pnpm-lock.yaml:pnpm install
Packages come from the package manager’s cache when they are there, the rest from the internet. See how to clear npm cache for that cache.
With MacWashing, it’s one click

System Junk in MacWashing lists the node_modules folders of projects you haven’t changed for 90 days under Project Dependencies, with their sizes, along with Composer, CocoaPods, Python and Cargo folders. They stay unchecked: they can be downloaded again, but that takes internet and time, so you pick what goes.
Free trial · macOS 14 or later
Questions and answers
Will MacWashing delete my own files when it cleans?
No. It removes only what it can match to a known app or a known kind of junk, in places apps leave files; macOS and Apple’s files are never touched. Anything debatable is marked and stays unchecked until you decide.
What about apps that are open?
If an open app holds files being cleaned, MacWashing waits for it to quit or quits it at your request, and opens it again afterwards.
Is it free?
Yes, within the free trial: System Junk and the Uninstaller free up to 25 GB in total, with no account or card needed.
Is it safe to delete node_modules?
Yes, in your own projects. It holds downloaded packages only, and one install command brings them back. Don’t delete the global node_modules folders in /usr/local/lib or /opt/homebrew/lib.
Why is node_modules so big?
It holds every package the project uses and every package those depend on, often hundreds or thousands. Each project with npm or Yarn keeps its own copy, so the same packages sit on your disk many times.
Does deleting node_modules in Finder take long?
Moving it to the Trash is quick, but emptying the Trash can take minutes, because the folder holds tens of thousands of small files. Deleting it in Terminal is usually faster, with this command in the project folder: rm -rf node_modules