Created
June 8, 2025 18:56
-
-
Save mohasinkr/e48e2f3d2c1b6ac61df0e6e5b8148cb4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import shutil | |
| from pathlib import Path | |
| def delete_node_modules(folder_path="."): | |
| folder = Path(folder_path) | |
| for root, dirs, _ in os.walk(folder): | |
| if "node_modules" in dirs: | |
| node_modules_path = Path(root) / "node_modules" | |
| print(f"Deleting: {node_modules_path}") | |
| shutil.rmtree(node_modules_path) | |
| if __name__ == "__main__": | |
| import sys | |
| folder_to_clean = sys.argv[1] if len(sys.argv) > 1 else "." | |
| delete_node_modules(folder_to_clean) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment