Trash your unused node_modules folders and regain hard drive space
jastuccio

jastuccio @jastuccio

About: Web Developer, Sailor, Stargazer, Hockey Player, and all around fun guy... but my absolute favorite thing is being a dad

Location:
Massachusetts
Joined:
Nov 15, 2019

Trash your unused node_modules folders and regain hard drive space

Publish Date: Mar 5 '21
5 0

If you are like me and have a lot of legacy projects on your computer you should consider deleting your node modules folder. A few minutes and a terminal command gave me back several GB of hard drive space!

before:
Alt Text

after:
Alt Text

I also ran this in another folder and saved 700mb

  • Before getting started make sure your projects backed up to Github or some-place safe.
cd directory-where-your-projects-live

find . -name "node_modules" -type d -prune -exec trash -rf '{}' +
Enter fullscreen mode Exit fullscreen mode

You can npm install dependencies to add them back to any projects where you need them.

  • If you don't have trash installed (and you probably should) use rm instead like this:

find . -name "node_modules" -type d -prune -exec rm -rf '{}' +

sources:
https://rtmccormick.com/2018/01/10/clear-node-modules-folders-recursively-mac-linux/

Comments 0 total

    Add comment