Skip to main content

Command Palette

Search for a command to run...

How to clear cache in npm

Published
•1 min read
How to clear cache in npm
D

I am 17 years old and a young passionate and self-taught frontend web developer and have an intention to become a successful developer. I usually write about JavaScript and Web Development and share some tips in the articles.

While creating the Next.js application via npm, I encountered an unknown error. I quickly searched on Google but didn't find a useful solution. Then, I thought of clearing the cache in npm. After removing the cache, I was able to create the Next.js application via npm.

In this article, I will show you a simple way of removing the cache in the npm.

Let's clean the cache 🗑

Run the following command:

npm cache clean

If this command doesn't work, run the following command:

npm cache clean --force

This will delete the npm cache from your computer.

What does the 'npm cache clean' command do?

When you install any package from the npm registry via npm, a cache folder is created on your computer.

So, when you install the same package again, npm will install it directly from the cache folder instead of having downloaded it from the NPM registry.

However, if several dependencies are installed in various versions, the cache may occasionally become corrupted. As a result, removing a cache will cause the package to be installed from the npm registry rather than the cache folder.

Thanks for reading

Follow me on Twitter

Thanks for reading!

12 views

More from this blog

D

Dhairya Shah

119 posts