1--- 2title: npm-cache 3section: 1 4description: Manipulates packages cache 5--- 6 7### Synopsis 8 9```bash 10npm cache add <package-spec> 11npm cache clean [<key>] 12npm cache ls [<name>@<version>] 13npm cache verify 14``` 15 16Note: This command is unaware of workspaces. 17 18### Description 19 20Used to add, list, or clean the npm cache folder. 21 22* add: 23 Add the specified packages to the local cache. This command is primarily 24 intended to be used internally by npm, but it can provide a way to 25 add data to the local installation cache explicitly. 26 27* clean: 28 Delete all data out of the cache folder. Note that this is typically 29 unnecessary, as npm's cache is self-healing and resistant to data 30 corruption issues. 31 32* verify: 33 Verify the contents of the cache folder, garbage collecting any unneeded 34 data, and verifying the integrity of the cache index and all cached data. 35 36### Details 37 38npm stores cache data in an opaque directory within the configured `cache`, 39named `_cacache`. This directory is a 40[`cacache`](http://npm.im/cacache)-based content-addressable cache that 41stores all http request data as well as other package-related data. This 42directory is primarily accessed through `pacote`, the library responsible 43for all package fetching as of npm@5. 44 45All data that passes through the cache is fully verified for integrity on 46both insertion and extraction. Cache corruption will either trigger an 47error, or signal to `pacote` that the data must be refetched, which it will 48do automatically. For this reason, it should never be necessary to clear 49the cache for any reason other than reclaiming disk space, thus why `clean` 50now requires `--force` to run. 51 52There is currently no method exposed through npm to inspect or directly 53manage the contents of this cache. In order to access it, `cacache` must be 54used directly. 55 56npm will not remove data by itself: the cache will grow as new packages are 57installed. 58 59### A note about the cache's design 60 61The npm cache is strictly a cache: it should not be relied upon as a 62persistent and reliable data store for package data. npm makes no guarantee 63that a previously-cached piece of data will be available later, and will 64automatically delete corrupted contents. The primary guarantee that the 65cache makes is that, if it does return data, that data will be exactly the 66data that was inserted. 67 68To run an offline verification of existing cache contents, use `npm cache 69verify`. 70 71### Configuration 72 73#### `cache` 74 75* Default: Windows: `%LocalAppData%\npm-cache`, Posix: `~/.npm` 76* Type: Path 77 78The location of npm's cache directory. 79 80 81 82### See Also 83 84* [package spec](/using-npm/package-spec) 85* [npm folders](/configuring-npm/folders) 86* [npm config](/commands/npm-config) 87* [npmrc](/configuring-npm/npmrc) 88* [npm install](/commands/npm-install) 89* [npm publish](/commands/npm-publish) 90* [npm pack](/commands/npm-pack) 91* https://npm.im/cacache 92* https://npm.im/pacote 93* https://npm.im/@npmcli/arborist 94* https://npm.im/make-fetch-happen 95