Store & Lockfile Settings

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. When enabled, pnpm opens the store's SQLite index.db in immutable mode (bypassing the WAL/-shm sidecar files that otherwise can't be created on a read-only directory) and suppresses every code path that would write to the store.

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.

Pair it with --offline and --frozen-lockfile against a fully-populated store:

pnpm install --frozen-store --offline --frozen-lockfile

The store must already contain everything the install needs, including the build output of any package whose lifecycle scripts are approved (or that has a patch applied). 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 is incompatible with --force and with a configured pnpr server, since both write into the store. pnpm store add and pnpm store prune fail while it is enabled. The side effects cache is not written either.

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 the index directory 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.

~/.config/pnpm/config.yaml
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: 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, виконується headless встановлення. Встановлення headless пропускає визначення всіх залежностей, оскільки йому не потрібно змінювати файл блокування.

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

Додайте повну URL-адресу tar-файлу пакунка до кожного запису у pnpm-lock.yaml.

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.

config.yaml
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:

pnpm-workspace.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.

  • resource pins the file at the tarball URL. That is the .tgz on most registries.
  • tar pins the uncompressed tar inside it, for registry packages, tarball: URLs, and file: tarballs alike.
pnpm-workspace.yaml
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.

pnpm-workspace.yaml
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 packages entry per package version and no snapshots section. The entry holds the package's metadata, its resolved dependencies, and under peerDependencies each 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 no peerDependenciesMeta field.
  • The tarball's integrity is a field of the entry. A registry package and an injected workspace package have no resolution field.
  • A local directory package records the dependencies its manifest declares, after hooks, in its dependencies and optionalDependencies. A dependency is its specifier alone when the specifier is also the version. Otherwise it is {specifier: ^1.0.0, version: 1.2.3}, without version when 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 the v9 format records no specifiers and keeps the existing freshness checks.
  • A project or local directory package dependency marked injected in dependenciesMeta has injected: true. The format records no other dependenciesMeta field.
  • A package installed with different peer dependencies lists what differs under snapshots in its entry.
  • Transitive peers without an external provider are normally inferred from dependencies. When necessary, unboundPeerDependencies records 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 empty with map keeps optional peers unbound when another copy binds them. A peer reference can carry its own with map 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 a workspace: dependency on another workspace project. Otherwise it is {specifier: ^1.0.0, version: 1.2.3} on one line. A dependency with a with map leaves out a version that follows from its specifier too.
  • A project that a workspace: dependency links to records its name.
  • The hash of a patched package is recorded once, under patchedDependencies. A package's deprecation message is not recorded.
  • The settings section holds everything the lockfile records from pnpm-workspace.yaml: the resolution settings, catalogs, overrides, patchedDependencies, ignoredOptionalDependencies and the two checksums. A catalog entry is its specifier alone when the version follows from it.
  • The resolution settings include the ones lockfile.includeResolutionSettings lists, 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, то відповідна назва файлу блокування буде pnpm-lock.feature-foo.yaml замість pnpm-lock.yaml. It is typically used in conjunction with the command line argument --merge-git-branch-lockfilesor by settingmergeGitBranchLockfilesBranchPatternin thepnpm-workspace.yaml` file.

mergeGitBranchLockfilesBranchPattern#

  • Стандартно: null
  • Тип: Array або 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.

Наприклад:

pnpm-workspace.yaml
mergeGitBranchLockfilesBranchPattern:
- main
- release*

Ви також можете виключити шаблони за допомогою !.

peersSuffixMaxLength#

  • Стандартно: 1000
  • Тип: number

Максимальна довжина суфікса ідентифікаторів прямих залежностей, що додається до ключів залежностей у файлі блокування. Якщо суфікс довший, він замінюється хешем.