How to Delete node_modules - Deep Nested Folder in Windows

前端 未结 30 920
逝去的感伤
逝去的感伤 2020-12-02 03:25

Upon trying to remove the node_modules directory created by npm install:

The source file name(s) are larger than is su

相关标签:
30条回答
  • 2020-12-02 04:14

    I had a similar problem and RD didn't work, for some unknown reason.

    NPM can get rid of its own mess though, so if you do npm uninstall [module-name] for each directory in node_modules, you'll get rid of them.

    (I'll look up how to batch loop this later, for those who have lots of dependencies.)

    0 讨论(0)
  • 2020-12-02 04:15

    You can use Git Bash to remove the folder:

    example: c:\users\olefrank\projects\mynodeproject

    rm -rf /c/users/olefrank/projects/mynodeproject

    0 讨论(0)
  • 2020-12-02 04:18

    Tried everything but didn't work. All the above methods did nothing. At last I was able to delete via VSCode.

    1. Just Open your root folder with VSCode.
    2. Select node_modules folder and delete.
    3. Profit. (It will take few milliseconds to delete.)

    0 讨论(0)
  • 2020-12-02 04:18

    I'm on windows 10 and I could'nt delete folders with message "directory not emtpy". Neither rimraf nor rm -rf worked.

    Copying an empty text file to every single folder did the trick - I was able to delete the complete node_modules folder.

    0 讨论(0)
  • 2020-12-02 04:19

    Delete Deep Netsted Folder like node_modules in Windows

    1. Option 1

      Delete using rimraf NPM package

      • Open command prompt and change your directory to the folder where node_modules folder exists.

      • Run

        rimraf node_modules

      • Missing rimraf ERROR then Install

        npm install rimraf -g

      • When the installation completes, run

        rimraf node_modules

    2. Option 2:

      Detele without installing anything

      • Create a folder with name test in any Drive

        robocopy /MIR c:\test D:\UserData\FolderToDelete > NUL

      • delete the folder test and FolderToDelete as both are empty

    Why this is an issue in windows?

    One of the deep nested folder structure is node_modules, Windows can’t delete the folder as its name is too long. To solve this, Easy solution, install a node module RimRaf

    0 讨论(0)
  • 2020-12-02 04:22

    I think this was not mentioned before. but the best way to delete unwanted node_modules is to install an utility called npmkill.

    Installation:

    From your terminal:

    npm i -g npkill
    

    And to use it:

    From your terminal:

    npkill
    

    You will then be presented with a list of projects, and by hitting space bar you can delete their node_modules.

    0 讨论(0)
提交回复
热议问题