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/v11/cache
18 - /cli-documentation/v11/cli-commands/cache
19 - /cli-documentation/v11/cli-commands/npm-cache
20 - /cli-documentation/v11/commands/cache
21 - /cli-documentation/v11/commands/npm-cache
22 - /cli-documentation/v11/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/v11/cache
30 - /cli/v11/cli-commands/cache
31 - /cli/v11/cli-commands/npm-cache
32 - /cli/v11/commands/cache
33 - /cli/v11/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 npm cache npx ls
46 npm cache npx rm [<key>...]
47 npm cache npx info <key>...
48 ```
49
50 Note: This command is unaware of workspaces.
51
52 ### Description
53
54 Used to add, list, or clean the `npm cache` folder. Also used to view info about entries in the `npm exec` (aka `npx`) cache folder.
55
56 #### `npm cache`
57
58 - 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.
59
60 - clean: Delete a single entry or all entries out of the cache folder. Note that this is typically unnecessary, as npm's cache is self-healing and resistant to data corruption issues.
61
62 - ls: List given entries or all entries in the local cache.
63
64 - 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.
65
66 #### `npm cache npx`
67
68 - ls: List all entries in the npx cache.
69
70 - rm: Remove given entries or all entries from the npx cache.
71
72 - info: Get detailed information about given entries in the npx cache.
73
74 ### Details
75
76 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.
77
78 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.
79
80 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.
81
82 npm will not remove data by itself: the cache will grow as new packages are installed.
83
84 ### A note about the cache's design
85
86 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.
87
88 To run an offline verification of existing cache contents, use `npm cache verify`.
89
90 ### Configuration
91
92 #### `cache`
93
94 - Default: Windows: `%LocalAppData%\npm-cache`, Posix: `~/.npm`
95 - Type: Path
96
97 The location of npm's cache directory.
98
99 ### See Also
100
101 - [package spec](/cli/v11/using-npm/package-spec)
102 - [npm folders](/cli/v11/configuring-npm/folders)
103 - [npm config](/cli/v11/commands/npm-config)
104 - [npmrc](/cli/v11/configuring-npm/npmrc)
105 - [npm install](/cli/v11/commands/npm-install)
106 - [npm publish](/cli/v11/commands/npm-publish)
107 - [npm pack](/cli/v11/commands/npm-pack)
108 - [npm exec](/cli/v11/commands/npm-exec)
109 - https://npm.im/cacache
110 - https://npm.im/pacote
111 - https://npm.im/@npmcli/arborist
112 - https://npm.im/make-fetch-happen