Skip to content

Instantly share code, notes, and snippets.

@pavelbinar
Last active April 25, 2024 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pavelbinar/2d4efe1ca7255005cfb97c94858db0fd to your computer and use it in GitHub Desktop.
Save pavelbinar/2d4efe1ca7255005cfb97c94858db0fd to your computer and use it in GitHub Desktop.
Delete all node_modules folders

Delete all node_modules folders

Recursively delete all node_modules folders nested in the current folder.

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

Since many node_modules contain another node_modules it is more effective to delete just top level folder. use -maxdepth 2 to limit that depth. Adjust according to your foldr structure.

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

Source: https://rtmccormick.com/2018/01/10/clear-node-modules-folders-recursively-mac-linux/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment