Coder Social home page Coder Social logo

Comments (31)

BrandonLive avatar BrandonLive commented on September 21, 2024 30

One tip that can help here: Hold Shift when you invoke the delete command (whether from keyboard or via the menu). This will invoke the permanent delete flow, rather than moving everything to the recycle bin. It should usually be near instantaneous.

Of course, make sure you really want to delete things before using this approach :-)

from windows-dev-performance.

zackpi avatar zackpi commented on September 21, 2024 18

4min 30sec - "Shift+Delete" aka "Permanently Delete"
45sec - "rm -Recurse -Force .\node_modules"
16sec - "rimraf .\node_modules"

An added benefit is that rimraf is cross-platform 😃

For comparison, I also have an M1 macbook, and running "rm -rf .\node_modules" takes about 15sec, so likely this is as good as it'll get

from windows-dev-performance.

orcmid avatar orcmid commented on September 21, 2024 14

I think I have very little skin in this particular game. I simply don't go there with projects and my projects are usually pretty small, befitting the size of my brain.

At the same time this strikes me as a kind of micro-managed compensation for badly-architected source, build structures, and out-of-control dependencies. I wonder what is served by pandering to that.

Now, I have been thinking that since pre-compiled headers and the ugliness of windows.h, so you can calibrate my attitude from that. I will now stifle myself for a few more years.

from windows-dev-performance.

wolfmanfp avatar wolfmanfp commented on September 21, 2024 12

It also happens when you copy a Node.js project from an SSD to a USB drive, it could even take half an hour.

from windows-dev-performance.

crediblebytes avatar crediblebytes commented on September 21, 2024 9

This should have way more traction. It takes more time to delete the folder than it does to run npm install, pull down all the packages and install them! Is this because all the files are not stored contiguously?

from windows-dev-performance.

schmorrison avatar schmorrison commented on September 21, 2024 7

In my case occasionally I need to delete node_modules to reinstall all packages. Instead of deleting node_modules directly I do the following:

~$ mv node_modules node_modules.del
~$ npm i 

And from the VSCode/File Explorer I Delete < node_modules.del

This way the packages can install under node_modules while node_modules.del is deleted. The deletion process is not quicker, but the reinstall can take place simultaneously. VSCode might complain about too many files to index until the folder is deleted if reinstalling at the same time.

from windows-dev-performance.

nmoinvaz avatar nmoinvaz commented on September 21, 2024 5

I ran a test to see the experience when using shift+delete. The experience is a bit better but it still takes a ton of time even when deleting permanently.

nodeshiftdel

When deleting files normally, Windows Explorer will enumerate all the files and see if the file sizes are too big to be recycled. If they are too big to be recycled Explorer will prompt asking if you want to permanently delete them. I think that a change could be made to Windows Explorer, that if it detected 10,000+ files it would ask if you want to permanently delete them as the delete operation could take a lot time. But even if Explorer had this change the delete option is no where near the speed it is on macOS.

from windows-dev-performance.

mswezey23 avatar mswezey23 commented on September 21, 2024 3

Been experiencing this issue for years now. As much as I love slingin code on Windows, this kills it for me...

from windows-dev-performance.

1mike12 avatar 1mike12 commented on September 21, 2024 3

I have nothing to add other than this has been something that's bothered me for so long but I've only just started to consciously look into it since working on a large project with a larger node_modules than before. rm -rf ing on a crappier macbook 3 years older should not be an order of magnitude faster than on windows.

from windows-dev-performance.

Khalilolgod avatar Khalilolgod commented on September 21, 2024 3

try rm -Recurse -Force .\node_modules\ in powershell inside the project directory.

from windows-dev-performance.

j471n avatar j471n commented on September 21, 2024 3

Use rmdir node_modules in Powershell inside the project directory.

from windows-dev-performance.

aminya avatar aminya commented on September 21, 2024 2

I recommend using fastcopy. It is much faster than Windows Explorer when it comes to doing operations on a large number of files.

image

It also happens when you copy a Node.js project from an SSD to a USB drive, it could even take half an hour.

When copying a large number of files to a slow USB drive, consider compressing the folder before copying.

from windows-dev-performance.

taleleuma avatar taleleuma commented on September 21, 2024 2

Fastest way for me is:

del /f/s/q node_mdules > nul
rmdir /s/q node_modules

Its an alternative. And it can't produce the same behavior, because instead of the file explorer its using a cmd window. Totally different UI.

Above solution is faster but not the fastest (compared to Mac or Linux). Kind of hacked solution. Plus, its not user-friendly and very risky to use on daily basis. Imagine, you copy-pasted del /f/s/q * > nul command on a wrong folder, say a default folder when you open command prompt. Your lose your windows user profile.

from windows-dev-performance.

xieyezi avatar xieyezi commented on September 21, 2024 1

4min 30sec - "Shift+Delete" aka "Permanently Delete" 45sec - "rm -Recurse -Force .\node_modules" 16sec - "rimraf .\node_modules"

An added benefit is that rimraf is cross-platform 😃

For comparison, I also have an M1 macbook, and running "rm -rf .\node_modules" takes about 15sec, so likely this is as good as it'll get

I found that rimraf is really much faster, thanks

from windows-dev-performance.

Eli-Black-Work avatar Eli-Black-Work commented on September 21, 2024

Taking another look at this, it feels like the most actionable of the original suggestions is this one:

  • Delete the folder immediately, and notify all apps of file deletes in the background.

I wonder if that would really speed things up? Seems like a nice idea, if so 🙂

from windows-dev-performance.

nathantaal avatar nathantaal commented on September 21, 2024

Plus one for this issue

from windows-dev-performance.

robertkraig avatar robertkraig commented on September 21, 2024

This is not just an issue with windows. I use a macbook pro 2015 w/ 16gb of ram. Also takes forever to delete a node_modules folder. I believe my experience was significantly faster on linux than either macos or windows. But macos ssd is not nearly as fast as you'd expect.

from windows-dev-performance.

mswezey23 avatar mswezey23 commented on September 21, 2024

This is not just an issue with windows. I use a macbook pro 2015 w/ 16gb of ram. Also takes forever to delete a node_modules folder. I believe my experience was significantly faster on linux than either macos or windows. But macos ssd is not nearly as fast as you'd expect.

I daily a MacBook Pro (2019, and now a 2020) and never had any issues with node_modules. Granted mine isn't 2015.

I also, for a brief period, had a previous gen Mac Mini that I upgraded its spinning rust to a (still on sata) SSD. Still magnitudes faster than a current day Windows machine running on a pcie (nvme) SSD attempting to delete a node_modules folder.

from windows-dev-performance.

chrisribe avatar chrisribe commented on September 21, 2024

Funny how and small project like https://fastcopy.jp/ can do it better than what windows can....
Especially on shift + delete, you would expect the same speed uggh :(

from windows-dev-performance.

jahidhassan2424 avatar jahidhassan2424 commented on September 21, 2024

It also happens when you copy a Node.js project from an SSD to a USB drive, it could even take half an hour.

just delete the node_modules folder then copy it. Copying process will be completed in a dew second. Then in the new location simply run "npm i". Note: you wont loosew any folder in node_modules. All of your dependencies will be downloaded with the command "npm i""

Second Option you can try: create zip file of that folder containing node_modules then copy it. But option 1 is more efficient.

from windows-dev-performance.

Jogai avatar Jogai commented on September 21, 2024

Fastest way for me is:

del /f/s/q node_mdules > nul
rmdir /s/q node_modules

Got it from https://stackoverflow.com/a/6208144/141243

from windows-dev-performance.

ikluhsman avatar ikluhsman commented on September 21, 2024

Fastest way for me is:

del /f/s/q node_mdules > nul
rmdir /s/q node_modules

Got it from https://stackoverflow.com/a/6208144/141243

This does not resolve the issue, it produces the same behavior as described in the original report.

from windows-dev-performance.

Jogai avatar Jogai commented on September 21, 2024

Fastest way for me is:

del /f/s/q node_mdules > nul
rmdir /s/q node_modules

Got it from https://stackoverflow.com/a/6208144/141243

This does not resolve the issue, it produces the same behavior as described in the original report.

Its an alternative. And it can't produce the same behavior, because instead of the file explorer its using a cmd window. Totally different UI.

from windows-dev-performance.

chrisribe avatar chrisribe commented on September 21, 2024

Fastest way for me is:

del /f/s/q node_mdules > nul
rmdir /s/q node_modules

Got it from https://stackoverflow.com/a/6208144/141243

It's a valid solution, just wish Microsoft would run that via the file explorer UI to avoid the long delete times.

from windows-dev-performance.

ikluhsman avatar ikluhsman commented on September 21, 2024

from windows-dev-performance.

Jogai avatar Jogai commented on September 21, 2024

Yes it does, see https://superuser.com/a/289399/471565

from windows-dev-performance.

xieyezi avatar xieyezi commented on September 21, 2024

Is there any other way to solve this problem? Such as one cli or plugin?

from windows-dev-performance.

batzen avatar batzen commented on September 21, 2024

You could also try using my tool to delete.
It should be much faster than the other tools.
Grab it from here https://github.com/batzen/Batzendev.Tools/releases/tag/v6.0.0 or install via chocolatey choco install batzendev.tools.
Feedback is appreciated.

from windows-dev-performance.

Jogai avatar Jogai commented on September 21, 2024

@batzen on your website it says that the tool is MIT licenced, but where is the actual source?

from windows-dev-performance.

batzen avatar batzen commented on September 21, 2024

MIT doesn't require published sources.
It's a private hobby project and I don't want to deal with all the overhead that comes with going OSS. I have enough OSS projects where I have to deal with all that. 😉
So the tool is free, but not OSS.

from windows-dev-performance.

wassimmohamed avatar wassimmohamed commented on September 21, 2024

below helped me..
https://spfx-app.dev/delete-the-nodemodules-folder-50-faster-on-windows

from windows-dev-performance.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.