pnpm store

Керування сховищем пакунків.

Команди#

status#

Checks the packages listed in the current project's lockfile for modifications in the project or global virtual store.

Повертає код виходу 0, якщо вміст пакунка такий самий, як і під час розпакування. Otherwise it fails with ERR_PNPM_MODIFIED_DEPENDENCY and lists the modified packages.

If an installed global-store package cannot be located or its project link points to a different slot, the command fails with ERR_PNPM_STORE_STATUS_UNVERIFIABLE. Run pnpm install before checking again.

add#

Функціонально еквівалентна pnpm add, за винятком того, що додає нові пакунки безпосередньо до сховища, не змінюючи жодних проєктів або файлів поза сховищем.

pnpm store add express@4

It also takes package tarballs or directories of tarballs that were downloaded some other way, searching directories recursively for .tgz, .tar.gz, and .tar archives. This prepares the store for an install without network access, such as a sandboxed build that downloads its sources ahead of time:

pnpm store add ./tarballs
pnpm install --offline --frozen-lockfile

An install takes a package from such a tarball when its lockfile entry pins that tarball. The entry's integrity can be the tarball's sha512 or sha1, or the hash of the uncompressed tar inside it, which lockfile.integrityTarget: tar records.

Run pnpm store add in the project it prepares the store for. It then reads the project's lockfile and prepares each tarball for every entry that pins it. This covers a dependency on a tarball URL, a package from a named registry, and a dependency on a git host such as GitHub when its entry records an integrity. Outside a project, a tarball only serves registry entries that name the package and version in its package.json.

prune#

Видаляє пакунки без посилань зі сховища.

Пакунки без посилань — це пакунки, які не використовуються жодним проєктом у системі. Пакунки можуть втратити посилання після більшості операцій встановлення, наприклад, коли залежності стають надлишковими.

Наприклад, під час pnpm install пакунок foo@1.0.0 буде оновлено до foo@1.0.1. pnpm зберігатиме foo@1.0.0 у сховищі, оскільки він не вилучає пакунки автоматично. Якщо пакунок foo@1.0.0 не використовується жодним іншим проєктом у системі, він стає таким, на який не посилаються. Виконання pnpm store prune вилучить foo@1.0.0 зі сховища.

Запуск pnpm store prune не є шкідливим і не має побічних ефектів для ваших проєктів. Якщо у наступних встановленнях знадобляться вилучені пакунки, pnpm завантажить їх знову.

Найкраще запускати pnpm store prune час від часу для очищення сховища, але не надто часто. Іноді пакунки без посилань знову стають потрібними. Це може статися при перемиканні гілок і встановленні старих залежностей, у цьому випадку pnpm потрібно буде повторно завантажити всі вилучені пакунки, що ненадовго сповільнить процес інсталяції.

Before pruning the store, pnpm deletes the expired entries of the pnx cache (see dlxCacheMaxAge), because they hold hard links into the store.

pnpm store prune also removes the package metadata cache: the metadata* directories in the cache directory and in its versioned subdirectories, such as v12/metadata. Other caches in the cache directory are kept. The next install downloads the metadata again.

Після очищення, pnpm показує загальний розмір видалених файлів.

If pnpm cannot decode a package index entry, it keeps the entry and reports the number of undecodable entries in the summary. Pruning continues for other entries. Keeping an index entry does not preserve its unreferenced files. A later install downloads the package again if it cannot reuse the stored files.

pnpm store prune keeps the wheels and source distributions that the pylock.toml of each registered Python project pins, so a later pnpm install --offline can recreate its environment. Unless frozenStore is enabled, an install tries to register each Python project that has an environment, even one whose store is inside it. A failed registration does not fail the install. A project installed by an earlier pnpm version is not registered until it is installed again. Pruning stops if a registered project's pylock.toml cannot be parsed.

pnpm store prune fails with ERR_PNPM_FROZEN_STORE_WRITE when frozenStore is enabled.

Since v12.7.0, pnpm store prune also removes private copies of pnpm or a runtime that a killed pnpm process left behind. pnpm makes such a copy when a project pins a version that another pnpm process is installing at that moment.

pnpm install registers the project in the projects directory of the store, "$(pnpm store path)/projects", with or without the global virtual store. Each entry is a symlink to the project directory, so ls -l "$(pnpm store path)/projects" lists the projects that use a store.

Without the global virtual store, an install with --frozen-store or enableModulesDir: false does not write the registry. Neither do --lockfile-only and --dry-run installs.

pnpm store prune removes the directory-clone cache used by local installs on macOS. Installed packages remain available, and later installs recreate the cache as needed. The cache requires the store and project to be on the same volume. A frozen store uses per-file imports when its cache is missing.

When the global virtual store is enabled, pnpm store prune also performs mark-and-sweep garbage collection on its links/ directory. It walks the registered projects to find the packages still in use and removes the rest. If no registered project links into links/, prune leaves it unchanged.

Pruning stops if a dependency link cannot be read.

path#

Повертає шлях до активної теки сховища.