How to Delete Deep Nested Folder like node_modules

2019-01-15 23:40发布

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

The source file name(s) are larger than is supported by the file system. Try moving to a location which has a shorter path name, or try renaming to shorter name(s) before attempting this operation

I also tried shift + delete and still having the same issue.

25条回答
在下西门庆
2楼-- · 2019-01-16 00:18

Try Visual Studio Code

After trying many solution i find this one is pretty simple. just open the project in Visual code and delete it. the UI may freeze for some seconds but it will definitely works.I test using many large size node_modules folder with it

enter image description here

Thanks

查看更多
家丑人穷心不美
3楼-- · 2019-01-16 00:18

go to your path using cmd where your node_modules folder and apply below command

npm install rimraf -g 
rimraf node_modules
查看更多
4楼-- · 2019-01-16 00:20

You can use Git Bash to remove the folder:

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

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

查看更多
一纸荒年 Trace。
5楼-- · 2019-01-16 00:20

simple just run for windows I haven't tested it for other operating systems

rm -r node_modules

in fact, you can delete any folder with this.

like rm -r AnyFolderWhichIsNotDeletableFromShiftDeleteOrDelete.

just open the gitbash move to root of the folder and run this command

Hope this will help.

Thanks, Ajay Kotnala

查看更多
聊天终结者
6楼-- · 2019-01-16 00:20

Advance a little beat for multiple folders...

If you have a project folder with multiple 'builds' that contains 'node_module'. Like:

C:/Project/build-1/node_modules
C:/Project/build-2/node_modules
C:/Project/build-3/node_modules
C:/Project/build-4/node_modules

You want to delete all folders starts with "build"

! First install nodejs and rimraf as suggested above !

Then go to path with project and run PowerShell command

cd  C:/Project/
Get-ChildItem build* | foreach {rimraf -Path $_.FullName}

It will take a wile

查看更多
祖国的老花朵
7楼-- · 2019-01-16 00:22

Just use powershell..

Run powershell and cd to the parent folder and then:

rm [yourfolder]

as in:

rm node_modules
查看更多
登录 后发表回答