I was shocked few minutes ago when I figured it out that Yarn cache on location /Users/user/Library/Caches/Yarn
takes more than 50GB of my disk space.
What the heck? Why is there every existing package in this universe on my computer?
I am glad that Yarn advertise itself as ultra fast, but in compensation with eating that much disk space I am not fan anymore. Now I even understand why yarn cache clean
takes years to finish its job.
Does Yarn cache all versions of particular package? Are there any plans in Yarn dev team to implement some kind of warning that cache is taking a lot of space and it could be cleared?
In addition to the answer, $ yarn cache clean removes all libraries from cache. If you want to remove a specific lib's cache run $ yarn cache dir to get the right yarn cache directory path for your OS, then $ cd to that directory and remove the folder with the name + version of the lib you want to cleanup.
yarn cache list [--pattern] Yarn stores every package in a global cache in your user directory on the file system. yarn cache list will print out every cached package. yarn cache list --pattern <pattern> will print out every cached package that matches the pattern provided.
yarn currently save cached packages in a default directory: /Users/<user>/Library/Caches/yarn or C:/Users/<user>/AppData/Local/Yarn/cache . When a lot of packages are cached, each user on the system to consume a lot of space on the primary drive.
Yarn website says the following:-
Yarn stores every package in a global cache in your user directory on the file system.
yarn cache list
& it will print out every cached package. Just in case you wanted to go through.yarn cache clean
& it will clean the cache (Note that it's a time taking process and considering your cache size this will be forever!)yarn cache dir
and it will display the path where it's storing the cache! You know what to do next, use rm -rf yarn-cache-dir
this will free up your space and clear all the cache as well.Note generally your yarn cache dir can be found at ~/.cache/yarn/
. In my system the cache is stored in ~/.cache/yarn/v6/
.
UPDATE:- It's recommended to use latest version of yarn.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With