스토어 & lockfile 설정
Store settings#
storeDir#
- 기본값:
- $PNPM_HOME 환경 변수가 설정된 경우 $PNPM_HOME/store
- $XDG_DATA_HOME 환경 변수가 설정된 경우 $XDG_DATA_HOME/pnpm/store
- Windows에서: ~/AppData/Local/pnpm/store
- macOS에서: ~/Library/pnpm/store
- Linux에서: ~/.local/share/pnpm/store
- 유형: path
모든 패키지가 저장되는 디스크 위치입니다.
저장소는 항상 설치가 발생하는 동일한 디스크에 있어야 합니다. 따라서 디스크당 하나의 저장소가 있도록 합니다. 현재 디스크에 홈 디렉토리가 있으면, 그 안에 저장소가 생성됩니다. 디스크에 홈이 없으면 파일 시스템의 루트에서 저장소가 생성됩니다. 예를 들어 /mnt에 마운트된 파일 시스템에서 설치가 진행되는 경우 스토어는 /mnt/.pnpm-store에 생성됩니다. Windows 시스템도 마찬가지입니다.
다른 디스크에서 저장소를 설정할 수 있지만, 이 경우 pnpm은 하드 링크 대신 저장소에서 패키지를 복사합니다. 하드 링크는 동일한 파일 시스템에서만 가능하기 때문입니다.
If no directory above the project accepts a hard link at all (an agent sandbox
that grants write access only to the project, or a container with just the
project bind-mounted writable), the store is created inside the project instead:
at node_modules/.pnpm-store. In a workspace, that is the workspace root's node_modules/.pnpm-store.
Putting it in the home directory there would either fail on a read-only home or
land on another volume, which copies every package instead of hard-linking it
(#13525).
pnpm keeps the locks that coordinate processes sharing a store outside the
store, in a per-user directory. On Linux and macOS that directory is
$XDG_RUNTIME_DIR when it is an absolute path to a directory the user owns
and can create files in (write and search permission), and other users cannot
write to. Otherwise the directory is /tmp. On Windows it is ~/AppData/Local. A sandbox that blocks writes to
/tmp can set XDG_RUNTIME_DIR to a directory it allows. Processes that use
the same store should see the same XDG_RUNTIME_DIR, since pnpm processes only
wait for each other when they share the lock directory.
important
이 pnpm 스토어는 서로 신뢰하는 사용자, 작업, 프로세스 간에만 공유하도록 설계되었습니다. 공유 storeDir을 구성하는 경우 신뢰할 수 없는 사용자가 쓸 수 없도록 파일 시스템 권한으로 보호하세요. 스토어는 pnpm의 신뢰 도메인에 속합니다. 패키지가 스토어에서 하드 링크될 수 있으며, 스토어 인덱스(index.db)에는 캐시된 파일을 검증하는 데 사용되는 해시가 기록됩니다.
verifyStoreIntegrity#
- 기본값: true
- 유형: Boolean
기본적으로 스토어의 파일이 수정된 경우, 해당 파일을 프로젝트의 node_modules에 링크하기 전에 파일 내용을 확인합니다. verifyStoreIntegrity가 false로 설정되면 설치 중에 콘텐츠 주소 지정 스토어의 파일을 확인하지 않습니다.
이 설정은 우발적인 스토어 손상을 감지하는 데 도움이 됩니다. 하지만 신뢰할 수 없는 사용자가 쓸 수 있는 스토어를 안전하게 만들어 주지는 않습니다. 스토어에 쓸 수 있는 공격자는 캐시된 패키지 내용과 이를 검증하는 데 사용되는 메타데이터를 모두 변경할 수 있기 때문입니다.
strictStorePkgContentCheck#
- 기본값: true
- 유형: Boolean
일부 레지스트리는 정확히 동일한 콘텐츠를 다른 패키지 이름 및/또는 버전으로 게시하는 것을 허용합니다. 이로 인해 스토어에 있는 패키지의 유효성 검사가 깨집니다. 스토어에서 이러한 패키지의 이름과 버전을 확인할 때 오류를 방지하려면 strictStorePkgContentCheck 설정을 false로 지정할 수 있습니다.
frozenStore#
- 기본값: false
- 유형: Boolean
Lets pnpm install run against a package store that lives on a read-only filesystem, for example a Nix store, a read-only bind mount, or an OCI image layer. 활성화하면 pnpm은 스토어의 SQLite index.db를 불변 모드로 열고(읽기 전용 디렉터리에서는 생성할 수 없는 WAL/-shm 사이드카 파일을 우회함) 스토어에 쓰기를 수행하는 모든 코드 경로를 억제합니다.
Ordinary installs can run in parallel and populate the same store on a local filesystem on the same machine. Leave frozenStore disabled for that use case.
With frozenStore enabled, no other process may modify the store during the install. Immutable reads bypass SQLite locking and can report "database disk image is malformed" if another job changes the database. This restriction does not apply to --frozen-lockfile, which still allows writes to the store.
완전히 채워진 스토어를 대상으로 --offline 및 --frozen-lockfile과 함께 사용하세요:
pnpm install --frozen-store --offline --frozen-lockfile
스토어에는 라이프사이클 스크립트가 승인된(또는 패치가 적용된) 모든 패키지의 빌드 출력을 포함하여 설치에 필요한 모든 것이 이미 들어 있어야 합니다. Under the global virtual store, those package directories live inside the store, so if a required build is missing the install fails up front with ERR_PNPM_FROZEN_STORE_NEEDS_BUILD. Seed the store with those builds first.
frozenStore는 --force 및 구성된 pnpr 서버와 호환되지 않는데, 둘 다 스토어에 쓰기 때문입니다. pnpm store add and pnpm store prune fail while it is enabled. 사이드 이펙트 캐시도 기록되지 않습니다.
storeIndexFormat#
Added in: v12.13.0
- Default: sqlite
- Type: sqlite, files
How the store records which files each package has.
sqlite: one SQLite database,index.db. SQLite's locking only works between processes on one machine, so this format is for a store on a local disk.files: one file per package in theindexdirectory of the store. Use it for a store on a network filesystem that several machines use at once, such as a store shared by CI jobs. Each entry is written to a temporary file and renamed into place, so concurrent jobs need no locks.
The format belongs to the store. pnpm creates the index directory the first time it writes to a store with storeIndexFormat: files, and from then on every pnpm process uses that directory for the store, whatever its own storeIndexFormat says. The packages recorded in an existing index.db are not carried over, so the first installs after switching download them again. To switch a store back to sqlite, delete its index directory.
storeDir: /mnt/shared/pnpm-store
storeIndexFormat: files
pnpm v11 reads only index.db, so it does not see the packages of a store that uses files.
Lockfile settings#
lockfile#
- 기본값: true
- 유형: Boolean
false로 설정하면 pnpm은 pnpm-lock.yaml 파일을 읽거나 생성하지 않습니다.
lockfileDir#
- Default: the workspace root with a shared lockfile, otherwise the project directory
- 유형: path
The directory in which pnpm-lock.yaml is created. Several projects may share a
single lockfile.
Setting lockfileDir to the workspace root of a workspace with a shared
lockfile, or to the project directory outside a workspace, has no effect. In a
workspace with sharedWorkspaceLockfile: false, setting lockfileDir makes the
projects share one lockfile in that directory.
The --lockfile-dir CLI option sets it for a single command. It cannot be used
with --global.
frozenLockfile#
- 기본값:
- CI가 아닌 경우: false
- CI의 경우: lockfile이 있으면 true
- 유형: Boolean
When set to true, pnpm fails the installation if the lockfile needs updating
or is missing.
In CI environments, this setting defaults
to true when a lockfile is present.
preferFrozenLockfile#
- 기본값: true
- 유형: Boolean
true로 설정되어 있고 사용 가능한 pnpm-lock.yaml이 package.json의 종속성 지시문을 충족하면 헤드리스 설치가 수행됩니다. 헤드리스 설치는 lockfile을 수정할 필요가 없기 때문에 모든 의존성 해결을 건너뜁니다.
excludeLinksFromLockfile#
- 기본값: false
- 유형: Boolean
When set to true, dependencies declared with the link: protocol are left
out of pnpm-lock.yaml. Dependencies that use the workspace: protocol are
still recorded.
lockfileIncludeTarballUrl#
- 기본값: false
- 유형: Boolean
pnpm-lock.yaml의 모든 항목에 패키지 tarball의 전체 URL을 추가합니다.
symlinkedLockfileTargetDirs#
Added in: v12.16.0
- 기본값: []
- 유형: string[]
When pnpm-lock.yaml is a symlink, pnpm reads it through the link but refuses to write changes to it. List the directories that the lockfile may link into, and pnpm writes the updated lockfile to the file the symlink points to if that file is inside one of them. pnpm follows the whole chain of links, keeps every link in place, and keeps the target file's permissions. A lockfile that does not change is never written.
symlinkedLockfileTargetDirs:
- ~/build/src
Each entry must be an absolute path or start with ~/. pnpm ignores any other entry.
Set it in the global configuration file or with PNPM_CONFIG_SYMLINKED_LOCKFILE_TARGET_DIRS='["/path/to/src"]'. pnpm ignores the setting in pnpm-workspace.yaml, because the repository that commits the symlink must not be the one that allows writing through it.
lockfile.includeResolutionSettings#
Added in: v12.10.0
- 기본값: false
- 유형: Boolean
When set to true, pnpm records these settings in the settings section of pnpm-lock.yaml:
lockfile:
includeResolutionSettings: true
A lockfile that records other values than the current settings is outdated. pnpm install resolves it again, and pnpm install --frozen-lockfile fails with ERR_PNPM_LOCKFILE_CONFIG_MISMATCH. Turning this setting on makes the next install resolve the lockfile once.
With autoDedupe, an install reuses a lockfile that records autoDedupe: true when nothing else changed. This also holds on a machine that did not write the lockfile, such as a server that runs pnpm install --frozen-lockfile and then pnpm run.
The v13 format always records these settings.
pnpm v11 and earlier v12 versions do not keep these settings and remove them when they rewrite the lockfile. pnpm v12 versions before v12.10.0 fail to read a pnpm-workspace.yaml that sets lockfile to an object. Turn this setting on when everyone working on the project uses v12.10.0 or later.
This setting needs local dependency resolution, so an install that is not frozen fails when pnprServer is set.
lockfile.integrityTarget#
Added in: v12.15.0
- Default: resource
- Type: resource, tar
Which hash the integrity of each package tarball in pnpm-lock.yaml pins.
resourcepins the file at the tarball URL. That is the.tgzon most registries.tarpins the uncompressed tar inside it, for registry packages,tarball:URLs, andfile:tarballs alike.
lockfile:
integrityTarget: tar
With tar, the lockfile no longer changes when a registry recompresses its tarballs, starts serving tar registries, or is replaced by a mirror that does either. pnpm checks every download by decoding it and hashing the tar. The hash it records comes from a .tgz that matched the registry's published integrity, so it is as trustworthy as that integrity. Git dependencies and registry revisions are unaffected: git dependencies pin a commit, and revisions always pin the tar.
The lockfile records the setting as integrityTarget: tar in its settings. A lockfile resolved under the other value is outdated. pnpm install resolves it again and rewrites every hash, and pnpm install --frozen-lockfile fails with ERR_PNPM_LOCKFILE_CONFIG_MISMATCH.
The store remembers the tar hash of every .tgz it extracts, whatever this setting says. A version already in the store therefore needs no download to learn its tar hash, and a frozen install finds its files under either hash. A version the store has not extracted is downloaded once to learn the hash, even by pnpm install --lockfile-only, and so is an optional dependency for another platform, which the lockfile records but no install on this machine extracts. Packages extracted by pnpm versions without this setting are downloaded once too.
pnpm audit signatures checks the registry signature of the .tgz and ties it to the tar hash in the lockfile, through the store or by downloading the package.
pnpm versions before v12.15.0 cannot install from a lockfile that pins tars. Turn this setting on when everyone working on the project uses v12.15.0 or later. A resolution by pnprServer cannot pin tars, so an install that is not frozen fails when pnprServer is set.
lockfile.format#
- Default: v9
- Type: v9, v13
The format pnpm writes pnpm-lock.yaml in. v13 is the format planned for pnpm 13. It is experimental and may change before pnpm 13 is released.
lockfile:
format: v13
A lockfile in the v13 format is JSON, indented with tabs, with a trailing comma after every entry. That is valid YAML, so pnpm-lock.yaml keeps its name and tools that read it as YAML still can. Its lockfileVersion is 13.0, the pnpm major planned to write the format by default.
The format differs from today's in these ways:
- The workspace projects are listed under
projects. - There is one
packagesentry per package version and nosnapshotssection. The entry holds the package's metadata, its resolved dependencies, and underpeerDependencieseach peer's declared range beside the version it resolved to. - An ordinary dependency on a peer's provider under another name stays in the dependency map for that name.
- A peer that a dependency below the package needs, rather than the package itself, is recorded as
{version: 1.2.3, below: true}. A peer the package marks optional is written as{specifier: '*', optional: true}. There is nopeerDependenciesMetafield. - The tarball's
integrityis a field of the entry. A registry package and an injected workspace package have noresolutionfield. - A local directory package records the dependencies its manifest declares, after hooks, in its
dependenciesandoptionalDependencies. A dependency is its specifier alone when the specifier is also the version. Otherwise it is{specifier: ^1.0.0, version: 1.2.3}, withoutversionwhen the package does not link the dependency in every snapshot. Frozen installs compare these specifiers with the current manifest. Changed ranges invalidate the lockfile even when the locked versions still satisfy them. A lockfile converted from thev9format records no specifiers and keeps the existing freshness checks. - A project or local directory package dependency marked
injectedindependenciesMetahasinjected: true. The format records no otherdependenciesMetafield. - A package installed with different peer dependencies lists what differs under
snapshotsin its entry. - Transitive peers without an external provider are normally inferred from dependencies. When necessary,
unboundPeerDependenciesrecords their names explicitly, including an empty list. - A reference between packages is a version, with no peer or patch suffix. Where that version alone does not say which copy of a package is meant, the reference names the copy by the peer dependencies it was resolved with, under
with, one per line. An emptywithmap keeps optional peers unbound when another copy binds them. A peer reference can carry its ownwithmap when its provider has different peer bindings. - A project's dependency is its specifier alone when the version follows from it: an exact version, a
catalog:entry, or aworkspace:dependency on another workspace project. Otherwise it is{specifier: ^1.0.0, version: 1.2.3}on one line. A dependency with awithmap leaves out a version that follows from its specifier too. - A project that a
workspace:dependency links to records itsname. - The hash of a patched package is recorded once, under
patchedDependencies. A package's deprecation message is not recorded. - The
settingssection holds everything the lockfile records frompnpm-workspace.yaml: the resolution settings,catalogs,overrides,patchedDependencies,ignoredOptionalDependenciesand the two checksums. A catalog entry is its specifier alone when the version follows from it. - The resolution settings include the ones
lockfile.includeResolutionSettingslists, whatever that setting says.
When a peer dependency is updated, only the lines that record it change.
Reading and writing the format#
pnpm reads lockfiles in both formats whatever this setting is. A regular install converts the lockfile when you change this setting. pnpm install --lockfile-only also writes the selected format. Versions of pnpm without this setting cannot read a lockfile in the v13 format. The format is still changing, so a lockfile written with this setting may need regenerating with a later pnpm.
The v13 format records the resolution settings. The next install resolves again a lockfile that does not record them yet, such as a v9 lockfile written without lockfile.includeResolutionSettings, or a v13 lockfile written by an earlier pnpm. pnpm install --frozen-lockfile fails on such a lockfile until a regular install records them. An install that is not frozen fails when pnprServer is set, because pnpr does not receive these settings.
The boot document that records config dependencies and the pinned pnpm version follows the pinned pnpm, not this setting. While the project pins pnpm 13 or earlier, it keeps today's format, so that a pnpm from before this format can read the pinned version and switch to it. A project that pins pnpm 14 or later gets a boot document in the v13 format.
gitBranchLockfile#
- 기본값: false
- 유형: Boolean
When set to true, the generated lockfile name after installation will be named
based on the current branch name to completely avoid merge conflicts. 예를 들어 현재 브랜치 이름이 feature-foo이면 해당 lockfile 이름은 pnpm-lock.yaml 대신 pnpm-lock.feature-foo.yaml이 됩니다. It is typically used
in conjunction with the command line argument --merge-git-branch-lockfiles or by
setting mergeGitBranchLockfilesBranchPattern in the pnpm-workspace.yaml file.
mergeGitBranchLockfilesBranchPattern#
- 기본값: null
- 유형: Array or null
This configuration matches the current branch name to determine whether to merge
all git branch lockfile files. By default, you need to manually pass the
--merge-git-branch-lockfiles command line parameter. This configuration allows
this process to be automatically completed.
예를 들어:
mergeGitBranchLockfilesBranchPattern:
- main
- release*
!를 사용하여 패턴을 제외할 수도 있습니다.
peersSuffixMaxLength#
- 기본값: 1000
- 유형: number
종속성 키에 추가되는 피어 ID 접미사의 최대 길이이며, 이는 lockfile에 적용됩니다. 접미사가 더 길면 해시로 대체됩니다.