{
  "id": 21030293,
  "title": "How to Find and Delete Old node_modules Folders on a Mac",
  "url": "https://urgent.news/2026/11/21/how-to-find-and-delete-old-node-modules-folders-on-a-mac",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-21T10:10:39.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/fastlog/how-to-find-and-delete-old-nodemodules-folders-on-a-mac-4427"
  },
  "original_language": "en",
  "account": "To safely remove outdated node_modules folders from a Mac, first determine how much space they occupy. Using the command \"find ~ (-path ~/Library -o -path ~/.Trash -o -name .git) -prune -o -type d -name node_modules -prune -exec du -sh {} +\" will list the largest top-level node_modules directories in your home folder. This should be run with caution, as it could accidentally delete important directories if not used correctly.\n\nNext, identify which projects are safe to clean. Any project with a node_modules folder not modified in the last 60 days can be considered safe for deletion. Running the command \"find ~/Projects -name node_modules -type d -prune -mtime +60 -exec du -sh {} +\" will show the size of each project's node_modules folder. Again, this should only be done after confirming that the project is not currently in use.\n\nNode_modules should not be deleted in active projects or projects that track dependencies in Git. Projects using pnpm may also require special attention, as they use a shared store to minimize duplication. In these cases, running \"pnpm store prune\" can help reclaim space.\n\nWhen deleting node_modules, it's best to use the \"rm -rf\" command to move the folder to the Trash rather than deleting it permanently. This allows for easy recovery if needed. Alternatively, npm kill can be used to interactively delete dependencies from a specific project.\n\nAfter deleting node_modules, it's necessary to re-install project dependencies using the appropriate npm, yarn, pnpm, or bun command. This ensures that all required packages are restored to their latest versions.\n\nWhile deleting node_modules can free up significant disk space, the immediate impact may not be noticeable. This is often due to space being temporarily reserved in the Trash or due to specific behaviors of package managers like pnpm. Therefore, it's important to manage expectations and allow some time for the space to be reclaimed.\n\nIn summary, deleting old node_modules folders on a Mac is a safe and effective way to reclaim disk space, provided that the projects are not currently in use and the package.json and lockfiles are intact. Always exercise caution when running cleanup commands and verify that the necessary dependencies will be re-installed before proceeding.",
  "summary": "Yes—you can safely delete node_modules folders in inactive projects on macOS. Every package inside node_modules can be reinstalled later with npm install , yarn , pnpm install , or bun install as long as your package.json and lockfile are intact. If you build side projects or use AI coding tools like Claude Code, Cursor, or Codex, node_modules folders pile up quickly across dozens of folders and…",
  "key_points": [
    "Use \"find\" command to list largest nodemodules directories",
    "Identify safe projects with nodemodules untouched in 60 days",
    "Use \"rm -rf\" to move folders to Trash, not delete permanently"
  ],
  "editors_take": "Targeted cleanup of inactive dependency folders offers developers a way to reclaim significant disk space while requiring careful verification to avoid disrupting active projects or breaking package manager stores.",
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}