Remove all node_modules directories recursively

06 May 2017

Here's a simple command to recursively delete all node_modules directories below the current directory within the tree.

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

Add this as an alias to bash ~/.bashrc or zsh ~/.zshrc to save having to type it all out each time.

alias node-delete='find . -name "node_modules" -type d -prune -exec rm -rf "{}" +'
Share this article
Was this post helpful?
Buy me a coffeeBuy me a coffee