To clear the npm package cache on Windows, run npm cache clean --force after checking which cache directory npm is using. This removes reusable cached package data, not the dependencies already installed in your project's node_modules. For an installation problem, try npm cache verify first; clearing the cache is mainly a disk-space decision.
Find the cache before cleaning
Open Start, search for Command Prompt, and open it under the Windows account you normally use for development. These instructions assume Node.js and npm are already installed. Check that npm runs:
npm --version
npm config get cache
The second command prints the effective cache location. The usual Windows default is %LocalAppData%\npm-cache, but configuration can change it. Copy the printed path into File Explorer's address bar, then open the folder's Properties to inspect its size. Do not delete anything yet.
Use the same terminal and account for the remaining commands. If your project has its own npm configuration, run the location check from that project's directory so you are checking the configuration that applies there. A terminal opened under another account can point to a different cache.
Also note the free space on the drive containing that folder, using File Explorer > This PC. If the cache is small, clearing it cannot explain or solve a much larger space problem. Check the actual size rather than relying on a screenshot of someone else's computer.
Verify first when an install fails
Stop running npm installs before maintenance. Then run:
npm cache verify
Verification checks cache integrity and removes unneeded cached data. It can change the cache, so do not treat it as a strictly read-only size report. If you specifically need to preserve today's cache state, stop before this command; npm does not offer an undo button for its cache maintenance.
The npm cache documentation explains why full deletion is usually unnecessary for corruption: npm checks cached data and can fetch it again when needed. Once verification completes, retry the installation that failed and read its actual error.
An authentication failure, an unavailable registry, or an incompatible dependency is a different problem. Do not repeat cleanup simply because an error includes the word npm. Keep the error text and identify which operation failed before changing another setting.
Clear cached package data to recover space
If you want the space and can download packages again later, run:
npm cache clean --force
This is destructive cache maintenance with no built-in rollback. The --force flag is required for this operation; it is not a recommendation to add force to unrelated npm commands. Deleted cache entries do not go through a normal File Explorer Recycle Bin workflow.
There is no command that restores the exact cache you removed. A later installation can fetch required package data again if the registry and your credentials are available. If you are about to work offline, or depend on a private registry you cannot currently reach, postpone cleanup rather than assuming everything can immediately be recovered.
After the command finishes, reopen the folder's Properties and compare drive free space. A remaining npm cache folder does not necessarily mean the command failed. The package cache lives within npm's cache area, and other npm data can remain there; do not turn the whole directory into a manual deletion target.
Keep project files separate from the shared cache
The shared cache and a project's installed dependencies answer different questions. The cache helps npm reuse package downloads across operations. A project's node_modules contains its installed dependency tree. Your source files and dependency manifests belong to the project.
For this cleanup, leave node_modules, package.json, and package-lock.json alone. Removing them is not part of the cache command. Deleting installed dependencies would create a separate reinstall task; deleting a lockfile can change how a future install resolves dependencies.
This distinction matters when several projects occupy the drive. A small shared cache can sit beside several large dependency trees. Cleaning the former will not remove the latter, and repeatedly clearing it will not produce the space occupied by those projects.
Do not apply npm commands to a pnpm store or a Yarn cache. Identify the package manager actually responsible for a folder before deciding how to maintain it.
A cache that grows again needs a different decision
New installations can populate the cache again. Decide whether the recurring downloads are worth keeping locally rather than setting up deletion after every install.
If you want future cache writes on another drive, npm supports a configured cache path. Choose a local folder on an available drive with enough free space; the example below assumes D: exists. Record the existing value from npm config get cache first, then run:
npm config set cache "D:\npm-cache" --location=user
npm config get cache
This changes a user setting; it does not move existing cache files. Project configuration or environment variables may override it, so trust the second command's result in the terminal where you install packages. The npm configuration reference describes configuration precedence.
To roll back, set the cache to the exact previous path you recorded. If you had no user-level cache override before, npm config delete cache --location=user removes the new override. An unavailable D: drive will make that setting unsuitable; restore it before another install.
Do not relocate the cache just because a different drive letter appears in an example. On a laptop with occasional removable storage, keeping the cache on an always-available drive can be the less troublesome choice.
When npm is not found or permission is denied
If Command Prompt cannot find npm, use the development environment in which npm normally works before attempting cleanup. Do not guess a cache path and delete it as a substitute for identifying the correct installation.
For a permissions error, confirm the printed path and the Windows account first. Close running installs and retry under your usual account. Avoid changing ownership of broad AppData directories or running every command as administrator to hide an unexplained access problem.
If this cache was not the main space consumer, continue with the Windows cleanup guide. Keep observations about npm separate from Windows update caches or personal downloads.
Reviewing developer caches with AiCleanDisk Pro
AiCleanDisk Pro includes npm cache among its auto-clean items, with developer items available through Show all items. Each item has a risk level and a confirmation dialog before cleaning. System-drive scanning and auto clean, except AI auto-clean, are free; scanning other drives, AI analysis, AI auto-clean items, and folder moving require a license. License access is $4.99 for 30 days, $16.90 for six months, or $19.90 for a year, paid once without automatic renewal.