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!