Cookie Consent by Free Privacy Policy Generator Aktuallisiere deine Cookie Einstellungen ๐Ÿ“Œ Remove all node_modules folder from PC


๐Ÿ“š Remove all node_modules folder from PC


๐Ÿ’ก Newskategorie: Programmierung
๐Ÿ”— Quelle: dev.to

If you ever thing that there are a lot of project you are working and you have lot of node_modules folder you have to delete to save up space when you only have 512SSD.

Here is a python script for deleting all those node_modules folder.

import os
import argparse
import shutil

all_node_path = []
block_path = ['$RECYCLE.BIN','System Volume Information']

def getNodeModulesPaths(path):    
    try:
        with os.scandir(path) as entries:
            for entry in entries:
                if entry.is_dir():
                    if(entry.name == 'node_modules'):
                        all_node_path.append(entry.path)
                    elif(entry.name in block_path):
                        continue
                    else:
                        getNodeModulesPaths(path+'/'+entry.name)
        return 1
    except Exception as e:
        print(f"An error occurred: {e}")
        return []

def remove_directory(directory_path):
    try:
        shutil.rmtree(directory_path)
        print(f"'{directory_path}' removed successfully.")
    except OSError as e:
        print(f"Error: {directory_path} : {e.strerror}")
def main():
    # arguments
    args_parser = argparse.ArgumentParser(description="CLI tool for removing all node_module folder for given path")
    args_parser.add_argument('-p', '--path', required=True, type=str,help="full path from where you want to remove node_module ")

    args = args_parser.parse_args()
    getNodeModulesPaths(args.path)
    for path in all_node_path:
        print(path)

    total_paths = len(all_node_path)

    confirm_rm = input("Are you sure you want to delete above "+str(total_paths)+" folder(y/n):").lower()
    if(confirm_rm == 'y'):
        for path in all_node_path:
            remove_directory(path)
        print("Removed "+str(total_paths)+' node_modules successfully!')
    return 1  
if __name__ == "__main__":
    main()

How to use it

Just run python main.py -p '<pathtofolder>' it is going to scan all node_modules folder in path and going to delete them.

Run it carefully also check the folders before confirming

Here is GitHub link for repo: github.com/kuldeepdev407/rm_node_modules

If i missed something in code feel free to create Issue Or PR.

...



๐Ÿ“Œ Remove all node_modules folder from PC


๐Ÿ“ˆ 53.13 Punkte

๐Ÿ“Œ Exclude node_modules folder from Time Machine backup


๐Ÿ“ˆ 38.69 Punkte

๐Ÿ“Œ warning: file /usr/lib/node_modules/npm/scripts/index-build.js: remove failed: No such file or directory warning: file


๐Ÿ“ˆ 37.31 Punkte

๐Ÿ“Œ Delete all node_modules folders from your system ?


๐Ÿ“ˆ 32.65 Punkte

๐Ÿ“Œ Rendertron 1.0.0 node_modules Attribute information disclosure


๐Ÿ“ˆ 27.76 Punkte

๐Ÿ“Œ Why is node_modules heavier than the universe? (No seriously, why is it so big?)


๐Ÿ“ˆ 27.76 Punkte

๐Ÿ“Œ Running out of disk space? Delete node_modules


๐Ÿ“ˆ 27.76 Punkte

๐Ÿ“Œ How to Resolve Corrupted node_modules with npm install --force


๐Ÿ“ˆ 27.76 Punkte

๐Ÿ“Œ Find and delete all files in folder, but don't delete the folder itself


๐Ÿ“ˆ 26.75 Punkte

๐Ÿ“Œ What distro of Linux when you open the downloads folder, identifies the folder as stn-12-5434?


๐Ÿ“ˆ 21.86 Punkte

๐Ÿ“Œ Symphony CMS up to 2.6.9 usererror.missing_extension.php existing-folder/new-folder directory traversal


๐Ÿ“ˆ 21.86 Punkte

๐Ÿ“Œ if someone opened a folder or files which are in a shared folder(mounted), can the sysadmin or security dudes see that in log file?


๐Ÿ“ˆ 21.86 Punkte

๐Ÿ“Œ Create hidden folder on Desktop | Folder Hacks


๐Ÿ“ˆ 21.86 Punkte

๐Ÿ“Œ How to Create a folder Having No Name? | Folder Hacks


๐Ÿ“ˆ 21.86 Punkte

๐Ÿ“Œ How to Use Androidโ€™s Secure Folder App To Secure Files and Folder


๐Ÿ“ˆ 21.86 Punkte

๐Ÿ“Œ Batch File Delete Folder: How to Automate Folder Deletion Using Batch Scripts


๐Ÿ“ˆ 21.86 Punkte

๐Ÿ“Œ Rename folder and subfolder based on property of first file in folder?


๐Ÿ“ˆ 21.86 Punkte

๐Ÿ“Œ Symphony CMS bis 2.6.9 usererror.missing_extension.php existing-folder/new-folder Directory Traversal


๐Ÿ“ˆ 21.86 Punkte

๐Ÿ“Œ Canโ€™t Move the Folder Because There is a Folder in the Same Location


๐Ÿ“ˆ 21.86 Punkte

๐Ÿ“Œ Symphony CMS bis 2.6.9 usererror.missing_extension.php existing-folder/new-folder Directory Traversal


๐Ÿ“ˆ 21.86 Punkte

๐Ÿ“Œ Canโ€™t Delete Folder? How to Force Delete Folder in Windows 10


๐Ÿ“ˆ 21.86 Punkte

๐Ÿ“Œ No Desktop folder in Users folder in Windows 11/10


๐Ÿ“ˆ 21.86 Punkte

๐Ÿ“Œ FTP Folder Error, Windows cannot access this folder


๐Ÿ“ˆ 21.86 Punkte

๐Ÿ“Œ Microsoft to Remove Downloads Folder from Disk Cleanup


๐Ÿ“ˆ 20.48 Punkte

๐Ÿ“Œ How to remove the Windows10Upgrade folder


๐Ÿ“ˆ 20.48 Punkte

๐Ÿ“Œ Add or Remove โ€œOpen file locationโ€ and โ€œOpen folder locationโ€ context menu in Windows


๐Ÿ“ˆ 20.48 Punkte

๐Ÿ“Œ How to remove the two blue arrows from a file or folder icon on Windows 10


๐Ÿ“ˆ 20.48 Punkte

๐Ÿ“Œ How to remove the two blue arrows from a file or folder icon on Windows 10


๐Ÿ“ˆ 20.48 Punkte

๐Ÿ“Œ How to remove the Windows10Upgrade folder


๐Ÿ“ˆ 20.48 Punkte

๐Ÿ“Œ iOS: remove photo access from all apps (change to manual select, not all)


๐Ÿ“ˆ 19.33 Punkte

๐Ÿ“Œ How to remove a remove apt repository from Debian


๐Ÿ“ˆ 19.1 Punkte

๐Ÿ“Œ How to remove a remove apt repository from Debian


๐Ÿ“ˆ 19.1 Punkte

๐Ÿ“Œ Remove From String in Python โ€“ How to Remove Characters from a String


๐Ÿ“ˆ 19.1 Punkte

๐Ÿ“Œ Python Remove from List โ€“ How to Remove an Item from a List in Python


๐Ÿ“ˆ 19.1 Punkte











matomo