Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 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.

like image 619
leoh Avatar asked Jan 27 '15 16:01

leoh


People also ask

Can I delete node_modules folder?

Using 'Git Bash' to remove the folder is the simplest way to remove all folders including subfolders in the 'node modules'. It will take a while to delete everything, but it works without any installation.

How do you clean node modules?

Clean up node_modules/ folder There are two ways to clean up the node_modules folder: Delete the folder and reinstall. Use npm prune (starting with npm version 6)

Where is node modules folder windows?

Node Modules Global installs on Unix systems go to {prefix}/lib/node_modules . Global installs on Windows go to {prefix}/node_modules (that is, no lib folder.)

Can I delete node_modules cache?

If you're sure you want to delete the entire cache, rerun this command with --force. So if you get that error, try running npm cache verify . If that doesn't solve your problem, you can also try deleting the node_modules folder in your project and re-running npm install .


2 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

[ http://www.nikola-breznjak.com/blog/nodejs/how-to-delete-node_modules-folder-on-windows-machine/ ]

like image 180
blub Avatar answered Oct 28 '22 11:10

blub


I've simply done that by using Winrar, this may seem a strange solution but working very well.

  • right click on node_modules folder
  • 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

like image 31
Eymen Elkum Avatar answered Oct 28 '22 12:10

Eymen Elkum