[{"data":1,"prerenderedAt":316},["ShallowReactive",2],{"blog-article-\u002Fblog\u002Fdelete-old-node-modules":3},{"id":4,"title":5,"author":6,"body":7,"category":296,"cover":297,"coverAlt":298,"description":299,"draft":300,"extension":301,"meta":302,"navigation":303,"path":304,"publishedAt":305,"seo":306,"stem":307,"tags":308,"topics":312,"translationKey":314,"updatedAt":305,"__hash__":315},"articles_en\u002Fblog\u002Fdelete-old-node-modules.md","How to Delete Old node_modules and Free Up Disk Space","Harry",{"type":8,"value":9,"toc":288},"minimark",[10,24,32,37,49,60,69,72,109,112,116,119,122,125,165,168,172,184,190,203,207,213,219,241,252,255,258,262,265,273,284],[11,12,13,14,18,19,23],"p",{},"Old websites, tutorial projects, and prototypes can keep taking up space long after you stop working on them. Much of that space may be in ",[15,16,17],"code",{},"node_modules",". ",[20,21,22],"strong",{},"You can delete an old project's dependency folder if you do not need it now and can reinstall the packages later, while keeping your source code."," You will need to restore the dependencies before running the project again.",[11,25,26,31],{},[27,28,30],"a",{"href":29},"\u002F","MangoDisk"," scans for supported project dependencies and build artifacts, listing their paths and sizes together. You can see which project each folder belongs to and choose what to remove without opening every old project to check its size.",[33,34,36],"h2",{"id":35},"find-old-project-dependencies-with-mangodisk","Find old project dependencies with MangoDisk",[11,38,39,40,44,45,48],{},"Open ",[27,41,43],{"href":42},"\u002Fdocs\u002Ffeatures\u002Fdeep-clean","Deep Cleanup"," and run a scan. If your projects are on another disk, open the arrow beside the scan button, select ",[20,46,47],{},"Choose Disks",", and add that disk to the scan.",[11,50,51],{},[52,53],"img",{"alt":54,"decoding":55,"height":56,"loading":57,"src":58,"width":59},"MangoDisk Deep Cleanup on macOS, showing cleanup categories, user-cache details, and selection controls","async",1263,"lazy","https:\u002F\u002Fassets.mangodisk.app\u002Fimages\u002Fscreenshots\u002Fen\u002Flight-01-deep-cleanup.jpg",1964,[11,61,62,65,66,68],{},[20,63,64],{},"Project dependency cleanup permanently deletes the selected content without using the Trash or Recycle Bin."," Back up any changes you made directly inside ",[15,67,17],{}," first. Reinstalling a package will not bring back those edits.",[11,70,71],{},"After the scan:",[73,74,75,83,93,96,102],"ol",{},[76,77,78,79,82],"li",{},"Choose ",[20,80,81],{},"Select none"," in the selection menu at the bottom so you can focus on this cleanup.",[76,84,39,85,88,89,92],{},[20,86,87],{},"Project build artifacts"," and expand ",[20,90,91],{},"Node.js build artifacts",".",[76,94,95],{},"Compare the paths and sizes to find projects you have put aside. If names are similar, open the folder to check which project it is; do not decide from its name or size alone.",[76,97,98,99,101],{},"Select only the ",[15,100,17],{}," folders you intend to remove. The same category may include framework build caches, so there is no need to select the entire group.",[76,103,104,105,108],{},"Stop the projects' development servers, builds, and package installations. Check the selected paths and estimated space, then click ",[20,106,107],{},"Clean"," and review the confirmation.",[11,110,111],{},"MangoDisk helps you find and compare scattered dependency folders. You still decide which projects can be put away. A large folder is not automatically an unused one.",[33,113,115],{"id":114},"which-projects-should-you-clean-first","Which projects should you clean first?",[11,117,118],{},"Start with projects you have finished and only want to keep as source: a tutorial you have completed, an old website, or a prototype you tried and set aside.",[11,120,121],{},"Keep dependencies for projects you are actively developing, need for an upcoming demo, or plan to use offline. Removing them can interrupt your work because running or building the project will usually require another installation first.",[11,123,124],{},"Before cleaning, keep these parts of the project:",[126,127,128,134,155],"ul",{},[76,129,130,133],{},[20,131,132],{},"Source code and assets:"," your code, pages, images, and other project files.",[76,135,136,139,140,143,144,147,148,151,152,92],{},[20,137,138],{},"Package manifests and lockfiles:"," ",[15,141,142],{},"package.json"," and the project's ",[15,145,146],{},"package-lock.json",", ",[15,149,150],{},"pnpm-lock.yaml",", or ",[15,153,154],{},"yarn.lock",[76,156,157,160,161,164],{},[20,158,159],{},"Configuration and local data:"," for example, ",[15,162,163],{},".env",", local databases, and uploaded files that are not backed up.",[11,166,167],{},"If a project depends on a private registry, an internal package source, or an old runtime, check that you can still install it later. Leave uncertain projects alone rather than trying to clean everything at once.",[33,169,171],{"id":170},"does-deleting-node_modules-clear-the-npm-cache","Does deleting node_modules clear the npm cache?",[11,173,174,175,177,178,92],{},"These are separate cleanup tasks. ",[15,176,17],{}," contains a project's installed dependencies; npm's download cache holds package data for reuse. They are normally stored in different locations. See the ",[27,179,183],{"href":180,"rel":181},"https:\u002F\u002Fdocs.npmjs.com\u002Fcli\u002Fv11\u002Fconfiguring-npm\u002Ffolders\u002F",[182],"nofollow","npm folder documentation",[11,185,186,187,189],{},"Clearing npm's cache therefore leaves old projects' dependency folders in place. Deleting one project's ",[15,188,17],{}," does not also empty the npm download cache.",[11,191,192,193,197,198,202],{},"If downloaded package data is what you want to remove, follow the ",[27,194,196],{"href":195},"\u002Fblog\u002Fclean-npm-cache","npm cache cleanup guide",". With pnpm, also keep ",[27,199,201],{"href":200},"\u002Fblog\u002Fclear-pnpm-store-cache","shared-store cleanup"," separate from removing a project's installed dependencies.",[33,204,206],{"id":205},"how-to-reinstall-dependencies-when-you-need-the-project","How to reinstall dependencies when you need the project",[11,208,209,210,212],{},"Return to the project root—the folder containing ",[15,211,142],{},"—and follow its original installation instructions.",[11,214,215,216,218],{},"For an npm project with a matching ",[15,217,146],{},", you can usually run:",[220,221,226],"pre",{"className":222,"code":223,"language":224,"meta":225,"style":225},"language-bash shiki shiki-themes github-light github-dark","npm ci\n","bash","",[15,227,228],{"__ignoreMap":225},[229,230,233,237],"span",{"class":231,"line":232},"line",1,[229,234,236],{"class":235},"sScJk","npm",[229,238,240],{"class":239},"sZZnC"," ci\n",[11,242,243,244,246,247,92],{},"This installs dependencies from the lockfile. If ",[15,245,17],{}," is still present, the command removes it first. If the manifest and lockfile do not match, it fails; do not delete the lockfile just to get past the error. See the ",[27,248,251],{"href":249,"rel":250},"https:\u002F\u002Fdocs.npmjs.com\u002Fcli\u002Fv11\u002Fcommands\u002Fnpm-ci\u002F",[182],"npm ci documentation",[11,253,254],{},"For projects that use pnpm or Yarn, keep using the original tool and project instructions rather than switching to npm and creating another lockfile. Installation may download packages and compile components, so wait for it to finish before starting the project.",[11,256,257],{},"If installation fails, check the required Node.js version, package source, and account access. Removing dependencies does not restore those prerequisites or guarantee that every old project will run immediately.",[33,259,261],{"id":260},"check-the-space-after-cleanup","Check the space after cleanup",[11,263,264],{},"Review MangoDisk's cleanup result and the disk's available space. If some folders could not be processed, check the reported reason. Stop any project still using them before trying again.",[11,266,267,268,272],{},"If the dependency folders are gone but the disk is still full, use ",[27,269,271],{"href":270},"\u002Fdocs\u002Ffeatures\u002Fdisk-analysis","Disk Space Analysis"," to see what else is in your project folders, such as video assets, datasets, or exported files. Review those separately rather than deleting a whole project as if it were only dependencies.",[11,274,275,279,280,92],{},[27,276,278],{"href":277},"\u002Fdownload","Download MangoDisk"," to check what your old projects have left behind. Keep the code you may return to, and remove the dependencies you do not currently need and can reinstall. For related tasks, browse the ",[27,281,283],{"href":282},"\u002Fblog\u002Ftopics\u002Fdeveloper-cleanup","developer cleanup guides",[285,286,287],"style",{},"html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":225,"searchDepth":289,"depth":289,"links":290},2,[291,292,293,294,295],{"id":35,"depth":289,"text":36},{"id":114,"depth":289,"text":115},{"id":170,"depth":289,"text":171},{"id":205,"depth":289,"text":206},{"id":260,"depth":289,"text":261},"Developer cleanup","\u002Fimages\u002Fblog\u002Fdelete-old-node-modules.webp","Documents stay inside project folders while an orange brush sweeps aside detachable package blocks","Find node_modules folders in old projects with MangoDisk, compare their sizes, and remove dependencies you can reinstall while keeping your source code and lockfiles.",false,"md",{},true,"\u002Fblog\u002Fdelete-old-node-modules","2026-11-16T13:56:58+08:00",{"title":5,"description":299},"blog\u002Fdelete-old-node-modules",[309,310,311],"delete node_modules","node_modules cleanup","old project dependencies",[313],"developer-cleanup","article-delete-old-node-modules","hjZn5ybxcyrSrvTyVY14EWXvVAuGooN5yIqpMoYwJlI",1794875701096]