Today I learnt: Clearing Yarn cache

Vamshi Suram
Dec 20, 2022

--

Over time, Yarn keeps caching your node modules and these tend to become huge, and the disk space gets lost unnoticed. These caches are stored in the following directory

/Users/<username>/Library/Caches/Yarn/

For me, it took some minutes to get rid of this cache, as it was around 20 GB.

Photo by Massimo Adami on Unsplash

To clear the cache, you can run the following commands. Be notified that these commands take a lot of time to finish executing based on the amount of cache it holds.

yarn cache clean

For more details on the options for the command, you can visit the official documentation. Optionally you can directly go to the cache path mentioned, and run a recursive delete on the directories as follows

rm -rf /Users/<username>/Library/Caches/Yarn/*

--

--

Vamshi Suram

Senior Frontend Engineer at Intuit. IIT Madras and IIT Bombay Alumni. 'apollo-mock-http' OSS project creator. Productivity Master. https://www.codegully.com