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