How to Safely Delete node_modules Folders on Windows and Reclaim Drive Space
JavaScript developers who clone multiple projects often accumulate tens of gigabytes in node_modules folders that are no longer needed, since these directories store installed dependencies and can be fully rebuilt by running npm install. On Windows, users can delete these folders via File Explorer, Command Prompt using rmdir /s /q, or PowerShell using Remove-Item -Recurse -Force. Deeply nested dependency trees can trigger path-too-long or access-denied errors due to Windows' historical 260-character path limit, which can be resolved by enabling long path support in Group Policy or using robocopy to empty the folder first. For developers with many old projects, the free command-line tool npkill can scan an entire drive, display each node_modules folder with its size, and allow selective deletion interactively. Beyond node_modules, related storage bloat from Docker Desktop, WSL2 disk images, and build caches from tools like Webpack or Vite can also accumulate silently and are not easily visible in Windows' built-in storage settings.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in