How to clear cache in npm? [Solution]


📋 Table Of Content

Here, in this article, we will learn how to clear or remove the cache from npm from windows, Linux, and mac.

What is npm?

npm (node package manager) is used when we need to install node packages to set up the development environment for a project locally in our system.

While working on a web project we do need to install lots of node packages using npm install <package name> command. As we install a lot of packages to work on different projects, it piles up a lot of cache in our file system which needs to be cleared as it may hamper our development with lots of node errors.

By default, the cache is stored in the%AppData%/npm-cache directory in windows and in Linux and, mac the cache is stored in~/.npm .

Clearing npm cache

To clear cache in npm, we need to run npm cache clean command in our terminal.

However, sometimes just the npm cache clean command doesn't work, so the better way is to run:

npm cache clean --force

OR

npm cache clean -f

The clean command will remove all the data present in the cache folder.

To verify if all the cache is cleared and removed from your file system, you can run this command in your terminal.

npm cache verify

💾 Recommended Articles