Clear the npm cache

Low risk
What do risk levels mean?
Read-only
Inspects state without changing anything.
Low risk
Reversible with a routine follow-up command.
Medium risk
Changes state; undo path documented.
Destructive
Deletes or overwrites; confirmation required.

Verifies the npm cache and, if problems persist, wipes it entirely so corrupted tarballs and metadata are re-downloaded on the next install.

nodenpmcache

Commands

Check cache integrity and garbage-collect invalid entries

npm cache verify

Delete the entire local npm cache

npm cache clean --force

Verification

npm cache verify

The cache verifies cleanly, with content re-added as installs run.

Undo

Not undoable

The cache is rebuilt automatically by subsequent installs; nothing irreplaceable is stored in it.

Pitfalls

  • npm cache verify alone fixes most cache corruption; the full clean is rarely necessary and makes the next install slower.
  • The --force flag is required because npm considers the cache self-healing and discourages manual cleaning.

Related