Couple of months ago I has having disk space problems on my development machine and started to look for unused folders that were taking some space. Looking for solutions on the internet, I've found that local node_moduless take a lot of space when you have a couple of Javascript projects. Then, I started looking for solutions on how to smartly delete these folders, since I can rebuild them with yarn if I need.
Just FYI, a raw npx create-react-app folder has a 227mb node_modules.
So, let's go to the recipe. I present you two ways of deleting these folders:
-
npx npkillwill spawn an interactive interface for you to select thenode_modulesyou want to delete. -
find . -name 'node_modules' -type d -prune -exec rm -rf '{}' +will find and delete everynode_modulesfolder under the current directory, so beware where you're running it.
If you want more options, check this SOF question.
Top comments (3)
yarn has a new system (plug n play) where there are no node_modules!
Yeah, Yarn 2 was a very cool release!
I'm still a bit afraid of migrating my projects to use it. One cool thing about
yarnvsnpmin the past was that it was almost seamless what you had to in your project...When I've first run this, I lost more than 13GB haha
So many angularjs projects...