Clear cache in Yarn: yarn cache clean

featured Image

In this article, we will learn why and how to clear cache in yarn from your local storage.

Yarn (Yet Another Resource Negotiator) is a package manager just like npm to manage our node project dependencies. It’s an open-source project created by Facebook to fix security and performance issues with npm.

Whenever we install any node packages using the yarn install command, it creates a cached copy of the package in our ~/.cache/yarn directory.

You can use the yarn cache dir command to find out the path to your cache directory in your system.

The Yarn package manager utilizes the cache files to optimize the installation process of the dependencies in our project. It directly installs the packages from the cache directory to our project folders, thereby saving time and internet usage.

However, since the cached files are not deleted automatically by the package managers, the package files get piled up with unused data and so the yarn cache takes up a lot of space in our local storage.

So it is better to clean the cache folder sometimes to avoid any error in package installations too.

Clear cache in Yarn

To clear the cache directory in yarn, we just have to use the yarn cache clean command in our terminal.

yarn cache clean

This command deletes all data stored in our cache directory.

Now, if you don’t want to clear all data from the cache folder, just some specific packages then you can use the yarn cache clean command along with the package name.

yarn cache clean <package name>

For example, I want to delete the flickity package from the cache, so it will write.

yarn cache clean flickity

You can also check the list of all the stored cached packages in your cache directory, you can use the command:

yarn cache list

It will list out all the name of the stored packages in your cache folder and then you can select the name of the unused package and delete it manually.


Related Topics:

Uninstall/Remove package using Yarn

How to clean cache in npm?

Related Posts

git commands with example

Top 40 Git commands with Examples

GitHub has become an essential tool for developers to manage, store, and collaborate with other developers on software projects. With its simple powerful git-based version control system, GitHub allows users…

Read more
Check GitHub Account in the Terminal

Check GitHub Account in the Terminal

GitHub is an integral tool for developers to store, manage, and collaborate on software projects with other developers. And as we work more and more in the command line it…

Read more
featured Image

How to make list of objects in Netlify CMS using list and object Widget

Here in this Netlify CMS tutorial we will how easily we can make a list of objects using list and object widgets. This will allow us to add multiple objects…

Read more

Leave a Reply

Your email address will not be published. Required fields are marked *