DEV Community

Dan Benitah
Dan Benitah

Posted on

Running out of space on a developer's machine

As developers, we often find our hard drives mysteriously filling up, slowing down our workflow.
First reflex is often to remove the waste and for developers, that includes downloaded packages that linger until we return our unused projects.
Let's explore a simple, yet powerful command-line I came across to reclaim hat precious disk space, making room for more coding and less clutter.

So I started with a 250 GB SD full

256GB full SD card

The commands we will need

Disk space

Command to get the disk space (I used an SD card smaller than my project folder until full).

 diskutil info -all
Enter fullscreen mode Exit fullscreen mode

You can also use

Remove a child folder from a directory

Looking for a command to recursively remove child node_module folder, I found the following command at https://stackoverflow.com/a/70549487/4819888 (it seems to have equivalents for Windows and Linux too)

find . -name '<folder to remove>' -type d -prune -print -exec rm -rf '{}' \;
Enter fullscreen mode Exit fullscreen mode

Cleaning up node_modules folders

find . -name 'node_modules' -type d -prune -print -exec rm -rf '{}' \;
Enter fullscreen mode Exit fullscreen mode

After running this command and clearing 22 node_module folders, it went down to 76GB

70% reduction disk space removing node_module folders

Cleaning up bin folders

find . -name 'node_modules' -type d -prune -print -exec rm -rf '{}' \;
Enter fullscreen mode Exit fullscreen mode

After running this command and clearing down 490 bin folders, I had a further 20 GB of additional free space.

space left after removing node_module folders and bin folders

I was thinking next we could tackle python packages but I could not find consistent naming convention though "pip" was what brought back most results. Also more on dangling docker images here. Anyway...

Conclusion

So here we are with a reduction of 78.43% of the space my projects took in no time.
What other folders shall we look to remove? Have you noticed similar savings?
What other tips might you have to share?

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay