Yarn cache large disk usage
It took 30GB prior to the time I cleared the cacheProblem
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
node_modules
of old projects (during this I discoverednpkill
, which made removing thesenode_modules
easier) - 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
Solution
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
Comments
Loading comments...
Tags
dev env
cli
yarn
Apply and earn a $2,500 bonus once you're hired on your first job!
Clients from the Fortune 500 to Silicon Valley startups
Choose your own rate, get paid on time
From hourly, part-time, to full-time positions
Flexible remote working environment
A lot of open JavaScript jobs!!
Fact corner: Referred talent are 5x more likely to pass the Toptal screening process than the average applicant.
Still hesitate? Read HoningJS author's guide on dealing with Toptal interview process.
Next Post
Count non-zero unique numbers
Previous Post
Straight-forward map