Yarn cache takes a lot of space

Viewed 8269

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?

1 Answers

Yarn website says the following:-

Yarn stores every package in a global cache in your user directory on the file system. 
  1. You can use yarn cache list & it will print out every cached package. Just in case you wanted to go through.
  2. You can use 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!)
  3. You can use 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.

Related