- npm keeps a cache of your install modules
so that it doesn't have to get them every time.
But that, sometimes, can lead to unexpected results.
And worse, turn out that doesn't work properly.
And this, sometimes, will be somewhat vague at first,
but in most cases, when you try to install the module,
that should be working properly, and it doesn't,
or a version of a module that doesn't work,
just try clearing your cache.
Npm's official docs say sometimes npm's cache
gets confused, and that is sometimes a reality
that will lead to hours of frustration.
Clearing your npm cache should always be part
of your troubleshooting steps when working with
modules and really not understanding what's happening.
Since npm five, the cache self heals.
But again, we're talking about a process
that is not fool-proof and you might need to force it.
So let me demonstrate a few commands worth knowing
to manage your cache.
The first that you need to know is npm cache verify.
And this will basically run a report
that will verify your cache.
And right now, as you can see, cache verified
and compress, content verified,
everything is good and dandy.
So there shouldn't be any problems.
But, if you find that you have problems
and you don't know what it is and maybe the cache needs
to be cleared, you can do a command that's called
npm cache clean
and then you need to force it
by doing dash dash force.
Otherwise it's not going to work.
Because now if you do simply npm cache clean,
what it's going to do is tell you,
well the cache self heals and you don't need to do this.
But if you want to force it, you need
to do dash, dash, force and it will clean the cache.
With these simple commands, you'll be able to find out
if there are any issues with your cache,
and if so, you can force clear your cache.