How to Delete Node_Modules - Deep Nested Folder in Windows
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...
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.
35 Answers
Since this the top google result, this is what worked for me:
Update, if you have npm v5, use npx:
npx rimraf ./**/node_modules
Otherwise install RimRaf:
npm install rimraf -g
And in the project folder delete the node_modules folder with:
rimraf node_modules
If you want to recursively delete:
rimraf .\**\node_modules
[ ]
I've simply done that by using Winrar, this may seem a strange solution but working very well.
- right click on
node_modulesfolder - select
Add to archive ...from the menu. - Winrar dialog opens
- just check the option
delete files after archiving - Don't forget to delete the node_modules.rar after finished.
[UPDATE] This also works with 7Zip
DELETE only by using DOS command without any installation:
Create an empty folder "test" on C or D drive and use following DOS command
robocopy /MIR c:\test D:\UserData\FolderToDelete > NUL
After completing above command, your folder will be empty, now you can delete the folder.
Don't worry your test folder will always be empty, so you can delete it at any time.
I used GitBash to remove de folder!
rm -r node_modules
It took a while to delete everything, but worked for me!
You can use Git Bash to remove the folder:
example: c:\users\olefrank\projects\mynodeproject
rm -rf /c/users/olefrank/projects/mynodeproject
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
Thanks
Delete Deep Netsted Folder like node_modules in Windows
Option 1
Delete using
rimrafNPM packageOpen command prompt and change your directory to the folder where
node_modulesfolder exists.Run
rimraf node_modulesMissing rimraf ERROR then Install
npm install rimraf -gWhen the installation completes, run
rimraf node_modules
Option 2:
Detele without installing anything
Create a folder with name
testin any Driverobocopy /MIR c:\test D:\UserData\FolderToDelete > NULdelete the folder
testandFolderToDeleteas 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
Please save yourself the need to read most of these answers and just use npx rather than trying to install rimraf globally. You can run a single command and always have the most recent version with none of the issues seen here.
npx rimraf ./**/node_modules
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
or alternatively, you can directly use it without installation by writing:
npx npkill
You will then be presented with a list of projects, and by hitting space bar you can delete their node_modules.
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
You can use Git Bash to remove the folder:
example: c:\users\stu\projects\mynodeproject
rm /c/users/stu/projects/mynodeproject -rfd
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.)
npm install -g remove-node-modules- cd to root and
remove-node-modules - or
remove-node-modules path/to/folder
Source:
I just do del node_modules inside my project folder on PowerShell, it will ask you if you want to remove it and its children folder, just hit 'Y' and that's it
On Windows Platform the simplest way is to use the terminal.
Please Run the command RMDIR /Q/S foldername to delete the folder and all of its subfolders.
Example: RMDIR /Q/S node_modules
The Above Command deletes node_modules folder and its subfolders.
For information please visit this
On Windows, using Total Commander all you have to do is select the folder click shift + delete . Don't forget about the shift key.
Any file manager allow to avoid such issues, e.g Far Manager
Tried everything but didn't work. All the above methods did nothing. At last I was able to delete via VSCode.
- Just Open your root folder with VSCode.
- Select
node_modulesfolder and delete. - Profit. (It will take
few millisecondsto delete.)
I made a Windows context item to fast delete node_modules or other folders. I use it when Windows doesn't delete a folder because of some invalid chars in the directory path.
Must Read
HOW TO INSTALL?
Install rimraf =>
npm install rimraf -gCreate a new file named
delete.bat, set the content as below and copy it intoc:\windows\system32\delete.bat:
@ECHO OFF
ECHO.
ECHO %CD%
ECHO.
ECHO Are you sure to delete the folder with Rimraf?
PAUSE
SET FOLDER=%CD%
CD /
rimraf "%FOLDER%"
rem DEL /F/Q/S "%FOLDER%" > NUL
rem RMDIR /Q/S "%FOLDER%"
EXIT
Run fast-delete.reg file to import into registry.
Done!
I needed to clean up an entire Projects directory for backup purposes, so I installed rimraf and ran this at the root dir (inside a git bash prompt):
find . -name "node_modules" -type d -prune -exec rimraf '{}' +
Very effective, truly recursive (avoids children node_modules) and fast on windows (thanks to rimraf).
Sources:
- The accepted answer in this question that suggests rimraf but lacks in the recursive aspect
This really worked for me:
npm i npkill
npx npkill
select with CURSORS and press SPACE key to delete
Just use powershell..
Run powershell and cd to the parent folder and then:
rm [yourfolder]
as in:
rm node_modules