guqrca
Last Updated: February 17, 2017
·
6.721K
· stevelacy
Social

Remove all node_module folders recursively

Remove all node_module folders (or any type of folder/file)

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

That will delete the folder and files even if there is a space in the name.

That saved me about 5GB over several hundred node projects which I had not touched in a while.
If I need the node modules back, I can simply run npm install

2 Responses
Add your response

28395

This helped me, thanks man :)

Don't you think adding -type d to the find command might improve it a little, so it would be

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

3 months ago ·
28525
2d62e386c079f824fe7f0c8e8e83128b

Include the "prune" argument to not go over children nodemodules.
```
find . -name "node
modules" -type d -prune -exec rm -rf '{}' +
```

2 months ago ·