Clearing node_modules
The node_modules
folder takes up a lot of space, especially if you have several projects in a folder. This simple bash command will help you clear all node_module
folders within the directory you are located in.
find . -name "node_modules" -type d -prune -exec rm -rf '{}' +
find .
- find in the current directory-name "node_modules"
- with the correct name-type d
- only directories-prune
- instructs find command not to descend into the current directory for it to exclude childnode_modules
directories.-exec rm -rf '{}' +
- executerm -rf
on the matching result. The'{}' +
will append each selected file name at the end, improving performance.