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
About
I am a London based web developer currently focused on JavaScript, Node and React. Get in touch if you wish to compare eslint configs or debate the deadliest enemy in videogame history (spoiler alert: it was the first goomba).
© 39digits 2021