Upon trying to remove the node_modules directory created by npm install
:
The source file name(s) are larger than is su
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.)
You can use Git Bash to remove the folder:
example: c:\users\olefrank\projects\mynodeproject
rm -rf /c/users/olefrank/projects/mynodeproject
Tried everything but didn't work. All the above methods did nothing. At last I was able to delete via VSCode.
node_modules
folder and delete.few milliseconds
to delete.)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.
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
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
I think this was not mentioned before. but the best way to delete unwanted node_modules
is to install an utility called npmkill
.
From your terminal:
npm i -g npkill
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
.