pnpm store

패키지 스토어를 관리합니다.

Commands#

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. A symlink to an archive is followed wherever it points. A symlinked directory is searched only if it points inside the directory. 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

If a tarball fails to fetch or extract, the warning identifies the archive and gives the cause. With --reporter=ndjson, the warning includes a tarball field.

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.

Since v12.25.0, pnpm store prune removes the Python environments in the store that no project uses. A project keeps the environment its .venv links to. If the project directory no longer exists, pnpm keeps its newest environment, since a moved project still links to it. Environments created by an earlier pnpm version are kept until the project is installed again.

Since v12.25.0, pnpm store prune also removes the Cargo crates in the store that no Cargo workspace links. Unless frozenStore is enabled, an install registers each Cargo workspace in the store. Only crates that pnpm added to the store since v12.25.0 are removed, because a workspace installed by an earlier pnpm version may still link the others. A workspace keeps every crate it has linked, including the crates its Cargo.lock no longer uses.

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, including every package once all registered projects are deleted. If the store has no projects directory, prune leaves links/ unchanged. An install that uses the global virtual store fails if it cannot register the project, unless the store is frozen.

Pruning stops if a dependency link cannot be read.

path#

활성 저장소 디렉토리에 대한 경로를 반환합니다.