Yarn cache large disk usage

It took 30GB prior to the time I cleared the cache


My primary drive, which boots the operating system, went below 500MB free of 136GB space

For a long time before, I blamed the amount comsumption for the usage of other applications

I gradually moved applications to another drive, and occasionally

  • clear temporary files
  • empty recycle bin
  • remove unused application

Time passed, and the problem still persisted. Then one day, it really bugged my work

  • installing dependencies on a new project could shut down the machine
  • using many web brower's tabs could lead to

Again, I usually had to remind myself of

  • removing unused
    of old projects (during this I discovered
    , which made removing these
  • close unused tabs, or even turned off the brower to clear all the cache that comsumption the remaining low disk space

Also, I purchased exteral storage to move the data there and merged partitions to the main primary driver to add more space

Time pass, the problem still persisted..

No more guessing, I searched online for a tool to check disk space usage of my drive and I found TreeSize (Windows application, for other OS, you could search for other solution of the same purpose)

And after minutes of scanning, it turned out that yarn folder took 30GB

Root cause

According to Classic Yarn (Yarn v1) doc

Yarn stores every package in a global cache in your user directory on the file system

Long story, short discovery


Yes, clear the cache, and it is safe. It will took some minutes depending on the cache size

1yarn cache clear

Consider migrating to the latest version of yarn. In this new version

  • by default, cache is configured to be local to project
  • cache strategy is enhanced
  • installing performance is improved


Loading comments...


dev env



Next Post

LeetCode: Make Array Zero by Subtracting Equal Amounts

Jul 31, 2022

Count non-zero unique numbers

Previous Post

LeetCode: Build Array from Permutation

Jul 26, 2022

Straight-forward map


Search Posts