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