Storage

Node modules and Docker images: why your Mac keeps filling up

Node modules and Docker can quietly take tens of gigabytes on a developer's Mac. Why they keep growing, why deleting them is only a temporary fix, and how to reclaim the space without disrupting your work.

Storage Studio Team 4 min read

Mac storage cleanup showing Docker images and Node modules taking up disk space
See what is quietly filling up your Mac storage, including Docker images and Node modules.

Nobody notices node modules or Docker eating their disk in real time. There's no warning and no dialog. You sort a folder by size one day and find a few dozen gigabytes you never decided to keep. The two fail in the same way: both are meant to be temporary, and both quietly stopped being temporary.

Why do node modules take up so much space?

One node modules folder isn't the problem. A typical web project lands somewhere between a few hundred megabytes and a gigabyte or so. The problem is how many there are. Package managers reduce duplication but don't remove it, so the same libraries turn up again and again across projects. Multiply that by every project you've cloned over a couple of years and it adds up to tens of gigabytes, without anyone choosing it.

Then there's what sits beside them: native binaries and downloaded browsers for test tools, plus a separate cache for each package manager you use. None of it shows up as one obvious folder. To see the folders themselves, run this in Terminal from your projects folder. It lists every node modules folder with its size:

find . -name node_modules -type d -prune -exec du -sh {} +

It's safe to delete node modules in a project you aren't working on. Your package manager recreates the folder from the lock file the next time you install. More on clearing them.

Why doesn't Docker give the space back?

Docker Desktop keeps every image, container, volume and build layer inside one large virtual disk file. It grows as you build and pull. Finder isn't a reliable way to measure it, because it can show the file at its full allowed size rather than what's really in use.

Docker's own commands show what's inside and clear it precisely, because only Docker knows which images are still in use:

docker system df
docker system prune
docker builder prune

Add -a to the prune to remove all unused images, and only add --volumes if you're sure no volume holds data you need. In Docker Desktop's Resources settings you can also lower the disk size limit, or choose where the disk image is stored. Why Docker uses so much space.

Why does the clean-up never stick?

Both rebuild. An install brings node modules back from the lock file, and a pull brings an image back the moment you need it. Deleting either costs nothing permanent; it trades space today for a slower install later. That's exactly why the clean-up never sticks. The work that filled the disk, cloning projects and building images, never stops. You haven't fixed anything. You've emptied the bucket.

How do you reclaim the space for good?

Two habits work better than a prune schedule.

  • Clear what tools rebuild, regularly. Package-manager caches, build caches and Docker's layer cache are safe to clear. The cost is a slower next build, not lost work.
  • Keep big, slow-moving data off the internal disk. Old projects, large caches and container data don't need the internal drive. They need to be somewhere your tools can find them.

That second part is where Storage Studio helps. Its Free Up Space cache step lists the well-known developer caches, including Xcode's derived data, Homebrew's downloads, npm, pip, cargo and yarn caches, and Docker's layer cache, each with its size, so you can untick anything you want to keep. What's Using Space shows Docker's data as its own row next to your largest folders, and big folders can be moved to a fast external drive with a link left at the original place, so your tools keep using the same paths. Moves can be reversed with Move back; cleared caches simply rebuild.

Keep a project on an external drive only if you're happy for builds to stop while it's unplugged, and prefer a Mac-formatted (APFS) drive, because some developer tools behave oddly on other formats. Developer projects on an external drive.

Reclaim your developer storageFree trial. For Apple silicon Macs on macOS 13 or later.

Frequently asked questions

Is it safe to delete node modules?

Yes, in projects you aren't working on. Your package manager recreates the folder from the lock file. Keep it in a project with no lock file if you need exactly the same versions back.

Does a Docker prune shrink the disk image?

It frees space inside Docker's disk image. How quickly that shows up as free space on your Mac depends on your Docker Desktop version and settings, so check with Docker's own disk usage command rather than Finder.

Which developer caches are safe to clear?

Package-manager caches, Xcode's derived data and Docker's build cache are all rebuilt by the tools that use them. Which ones Storage Studio clears.

Related reading: How to free up space used by Xcode, and How to manage Mac storage across your Mac, cloud and drives.

DockerNode.jsnode modulesdeveloper toolsMac storageexternal drive