11cb0ef41Sopenharmony_ci---
21cb0ef41Sopenharmony_cititle: npm-cache
31cb0ef41Sopenharmony_cisection: 1
41cb0ef41Sopenharmony_cidescription: Manipulates packages cache
51cb0ef41Sopenharmony_ci---
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ci### Synopsis
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ci```bash
101cb0ef41Sopenharmony_cinpm cache add <package-spec>
111cb0ef41Sopenharmony_cinpm cache clean [<key>]
121cb0ef41Sopenharmony_cinpm cache ls [<name>@<version>]
131cb0ef41Sopenharmony_cinpm cache verify
141cb0ef41Sopenharmony_ci```
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ciNote: This command is unaware of workspaces.
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_ci### Description
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_ciUsed to add, list, or clean the npm cache folder.
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ci* add:
231cb0ef41Sopenharmony_ci  Add the specified packages to the local cache.  This command is primarily
241cb0ef41Sopenharmony_ci  intended to be used internally by npm, but it can provide a way to
251cb0ef41Sopenharmony_ci  add data to the local installation cache explicitly.
261cb0ef41Sopenharmony_ci
271cb0ef41Sopenharmony_ci* clean:
281cb0ef41Sopenharmony_ci  Delete all data out of the cache folder.  Note that this is typically
291cb0ef41Sopenharmony_ci  unnecessary, as npm's cache is self-healing and resistant to data
301cb0ef41Sopenharmony_ci  corruption issues.
311cb0ef41Sopenharmony_ci
321cb0ef41Sopenharmony_ci* verify:
331cb0ef41Sopenharmony_ci  Verify the contents of the cache folder, garbage collecting any unneeded
341cb0ef41Sopenharmony_ci  data, and verifying the integrity of the cache index and all cached data.
351cb0ef41Sopenharmony_ci
361cb0ef41Sopenharmony_ci### Details
371cb0ef41Sopenharmony_ci
381cb0ef41Sopenharmony_cinpm stores cache data in an opaque directory within the configured `cache`,
391cb0ef41Sopenharmony_cinamed `_cacache`. This directory is a
401cb0ef41Sopenharmony_ci[`cacache`](http://npm.im/cacache)-based content-addressable cache that
411cb0ef41Sopenharmony_cistores all http request data as well as other package-related data. This
421cb0ef41Sopenharmony_cidirectory is primarily accessed through `pacote`, the library responsible
431cb0ef41Sopenharmony_cifor all package fetching as of npm@5.
441cb0ef41Sopenharmony_ci
451cb0ef41Sopenharmony_ciAll data that passes through the cache is fully verified for integrity on
461cb0ef41Sopenharmony_ciboth insertion and extraction. Cache corruption will either trigger an
471cb0ef41Sopenharmony_cierror, or signal to `pacote` that the data must be refetched, which it will
481cb0ef41Sopenharmony_cido automatically. For this reason, it should never be necessary to clear
491cb0ef41Sopenharmony_cithe cache for any reason other than reclaiming disk space, thus why `clean`
501cb0ef41Sopenharmony_cinow requires `--force` to run.
511cb0ef41Sopenharmony_ci
521cb0ef41Sopenharmony_ciThere is currently no method exposed through npm to inspect or directly
531cb0ef41Sopenharmony_cimanage the contents of this cache. In order to access it, `cacache` must be
541cb0ef41Sopenharmony_ciused directly.
551cb0ef41Sopenharmony_ci
561cb0ef41Sopenharmony_cinpm will not remove data by itself: the cache will grow as new packages are
571cb0ef41Sopenharmony_ciinstalled.
581cb0ef41Sopenharmony_ci
591cb0ef41Sopenharmony_ci### A note about the cache's design
601cb0ef41Sopenharmony_ci
611cb0ef41Sopenharmony_ciThe npm cache is strictly a cache: it should not be relied upon as a
621cb0ef41Sopenharmony_cipersistent and reliable data store for package data. npm makes no guarantee
631cb0ef41Sopenharmony_cithat a previously-cached piece of data will be available later, and will
641cb0ef41Sopenharmony_ciautomatically delete corrupted contents. The primary guarantee that the
651cb0ef41Sopenharmony_cicache makes is that, if it does return data, that data will be exactly the
661cb0ef41Sopenharmony_cidata that was inserted.
671cb0ef41Sopenharmony_ci
681cb0ef41Sopenharmony_ciTo run an offline verification of existing cache contents, use `npm cache
691cb0ef41Sopenharmony_civerify`.
701cb0ef41Sopenharmony_ci
711cb0ef41Sopenharmony_ci### Configuration
721cb0ef41Sopenharmony_ci
731cb0ef41Sopenharmony_ci#### `cache`
741cb0ef41Sopenharmony_ci
751cb0ef41Sopenharmony_ci* Default: Windows: `%LocalAppData%\npm-cache`, Posix: `~/.npm`
761cb0ef41Sopenharmony_ci* Type: Path
771cb0ef41Sopenharmony_ci
781cb0ef41Sopenharmony_ciThe location of npm's cache directory.
791cb0ef41Sopenharmony_ci
801cb0ef41Sopenharmony_ci
811cb0ef41Sopenharmony_ci
821cb0ef41Sopenharmony_ci### See Also
831cb0ef41Sopenharmony_ci
841cb0ef41Sopenharmony_ci* [package spec](/using-npm/package-spec)
851cb0ef41Sopenharmony_ci* [npm folders](/configuring-npm/folders)
861cb0ef41Sopenharmony_ci* [npm config](/commands/npm-config)
871cb0ef41Sopenharmony_ci* [npmrc](/configuring-npm/npmrc)
881cb0ef41Sopenharmony_ci* [npm install](/commands/npm-install)
891cb0ef41Sopenharmony_ci* [npm publish](/commands/npm-publish)
901cb0ef41Sopenharmony_ci* [npm pack](/commands/npm-pack)
911cb0ef41Sopenharmony_ci* https://npm.im/cacache
921cb0ef41Sopenharmony_ci* https://npm.im/pacote
931cb0ef41Sopenharmony_ci* https://npm.im/@npmcli/arborist
941cb0ef41Sopenharmony_ci* https://npm.im/make-fetch-happen
95