레지스트리

The registries setting in pnpm-workspace.yaml declares each registry a project installs from, once, keyed by the registry's URL. pnpm이 레지스트리에 대해 아는 모든 정보는 해당 항목에 담깁니다. 즉, 그 레지스트리로 라우팅되는 스코프, 그 레지스트리가 응답하는 bare specifier 접두사, 그리고 그 뒤에 있는 서버의 특성입니다.

pnpm-workspace.yaml
registries:
  https://npm.corp.example.com/:
    serverType: artifactory
    scopes: ["@acme", "@corp-tools"]
    prefix: work
  https://verdaccio.corp.example.com/:
    scopes: ["@"]
    supportsTimeField: true

항목의 모든 정보가 해당 서버에 관한 정보이기 때문에 URL이 키가 됩니다. 만약 tarball 레이아웃의 키가 스코프라면, 레이아웃은 스코프가 현재 가리키는 대상에 묶이게 되고, 스코프가 서로 다르게 해석되는 두 개발자는 어떤 URL을 생략할 수 있는지에 대해 서로 다른 lockfile을 작성하게 됩니다.

항목에는 다음 필드를 포함할 수 있습니다:

필드 유형 선언하는 내용
scopes string[] 이 레지스트리로 라우팅되는 패키지 스코프입니다.
ecosystem string The package ecosystem, npm, cargo, or pypi.
packages string[] The Python package names or prefixes routed to this registry.
prefix string 이 레지스트리가 응답하는 bare specifier 접두사입니다.
serverType string How the server lays out tarball URLs: npm, artifactory, or pnpr.
supportsTimeField boolean 서버의 축약 메타데이터에 time 필드가 포함되는지 여부입니다.
networkConcurrency number The most requests pnpm keeps in flight to this registry's origin.

그 밖의 필드는 거부됩니다. In particular, credentials (_authToken, _auth, _password, username, tokenHelper) and TLS material (ca, cafile, cert, certfile, key, keyfile) are refused rather than silently ignored. pnpm-workspace.yaml is committed to the repository, so they belong in .npmrc (e.g. //npm.corp.example.com/:_authToken=...). 같은 이유로 user:pass@ 자격 증명이 포함된 URL 키도 거부됩니다.

패키지를 레지스트리로 라우팅하기#

scopes#

패키지가 이 레지스트리에서 해석되는 스코프로, @ 접두사를 붙입니다. A bare "@" routes the scope-less default registry, the same registry the registry setting names:

pnpm-workspace.yaml
registries:
  https://npm.corp.example.com/:
    scopes: ["@acme"]
  https://registry.internal.example.com/:
    scopes: ["@"]

하나의 스코프는 정확히 하나의 레지스트리로 해석되므로, 두 항목에서 같은 스코프를 라우팅하면 오류가 발생합니다.

prefix#

"lib": "work:^2.0.0"에서처럼 이 레지스트리가 응답하는 이름 있는 레지스트리 접두사입니다:

pnpm-workspace.yaml
registries:
  https://npm.work.example.com/:
    prefix: work
pnpm add work:@corp/lib@^2.0.0

각 항목은 최대 하나의 접두사를 선언하며, 두 항목이 같은 접두사를 선언할 수 없습니다. 접두사는 lockfile 패키지 키(foo@work:1.0.0)에서 레지스트리의 식별자이므로, 두 번째 표기가 있으면 같은 레지스트리의 같은 패키지가 두 번 키로 지정되기 때문입니다.

Prefixes declared here follow the same rules as the deprecated namedRegistries setting they replace: the built-in gh: and npmjs: aliases can be overridden by declaring their prefix on your own URL, reserved names are rejected, and packages resolved from a registry that declares a prefix get registry-qualified lockfile keys, whether a dependency names the prefix or a scopes entry routes it there.

서버 설명하기#

serverType#

모든 레지스트리가 npm 레지스트리와 같은 방식으로 tarball URL을 구성하는 것은 아닙니다. pnpm omits a tarball URL from pnpm-lock.yaml when it can rebuild the URL from the package's name, version, and registry. The lockfile then carries no host-specific URL for that package, and renaming or moving the registry does not churn the lockfile. Whether pnpm can rebuild a URL depends on the server, and serverType is where you declare it:

serverType 의미
선언되지 않음 엄격 모드: tarball URL이 정확히 표준 npm 레이아웃 URL(<registry>/<name>/-/<scopeless-name>-<version>.tgz)인 경우에만 생략됩니다. registry.npmjs.org를 제외한 모든 레지스트리는 기본적으로 이 방식으로 처리됩니다.
npm 서버가 registry.npmjs.org처럼 동작합니다. 즉, 스코프 패키지를 인코딩되지 않은 경로뿐만 아니라 퍼센트 인코딩된 경로(/@acme%2Fwidget/...)에서도 제공합니다. 공개 레지스트리를 충실히 미러링하거나 캐싱하는 프록시가 이에 해당합니다. registry.npmjs.org 자체에는 기본으로 적용됩니다.
artifactory 서버가 스코프 패키지의 tarball 파일 이름에 스코프를 반복합니다: @acme/widget/-/@acme/widget-1.0.0.tgz. 반면 npm 레이아웃에서는 스코프가 제거됩니다(@acme/widget/-/widget-1.0.0.tgz).
pnpr The server serves a version's tarball at <registry>/<name>@<version>, such as @acme/widget@1.0.0. pnpr uses this layout on both .tgz registries and tar registries, except for a version with registry revisions. pnpm also sends release notes to the server and reads them from it.

JFrog Artifactory 레지스트리의 경우, 이 설정에 따라 lockfile이 모든 스코프 패키지에 대해 호스트별 tarball URL을 기록하거나 하나도 기록하지 않게 됩니다:

pnpm-workspace.yaml
registries:
  https://acme.jfrog.example.com/artifactory/api/npm/npm-virtual/:
    serverType: artifactory
    scopes: ["@acme"]

일반적인 서버별 값:

서버 serverType
JFrog Artifactory artifactory
GitLab 패키지 레지스트리 artifactory. It uses the same layout, repeating the scope in the filename.
npm 레지스트리를 충실히 미러링하거나 캐싱하는 프록시 npm
pnpr pnpr
Verdaccio, Sonatype Nexus, Azure Artifacts None needed. They serve the exact canonical npm layout, which the strict default already reconstructs.
GitHub Packages None. Its download URLs contain a content digest that cannot be derived from the package's identity, so they are kept in the lockfile.
GitHub Enterprise Server None. It serves a scoped package only from the percent-encoded path, which the strict default keeps in the lockfile and requests verbatim.

A registry declared serverType: pnpr is also asked for pnpr's own package document, which is smaller than npm's and carries what only pnpr records: the selected registry revision of each version and the facts pnpr verified about each archive, such as whether it needs a build. A large document leaves out the manifests of the versions a resolution rarely picks, and pnpm fetches the manifest of such a version when it picks one. pnpm keeps these documents in v12/metadata-pnpr in the cache directory, apart from npm's documents.

pnpr's package document supports a minimumReleaseAge of at most 43200 minutes (30 days). A longer one fails the resolution with ERR_PNPM_UNSUPPORTED_MINIMUM_RELEASE_AGE when pnpm reads a package from a registry declared serverType: pnpr. The window counts back from the current time, so a referenceTime in the past adds how far it lags. With referenceTime set and trustPolicy: no-downgrade, a trustPolicyIgnoreAfter window is counted the same way, and one that reaches 43200 minutes fails the resolution with ERR_PNPM_UNSUPPORTED_TRUST_POLICY_IGNORE_AFTER.

A pnpr server identifies itself in its responses. When a registry that is not declared serverType: pnpr turns out to be pnpr, pnpm warns once and installs from npm's documents, without revisions or pnpr's facts about the archives.

레이아웃은 추론되지 않고 반드시 선언해야 합니다. 가상 저장소는 각 패키지가 업스트림에서 동기화되었는지 로컬에서 게시되었는지에 따라 두 레이아웃을 동시에 제공할 수 있으므로, pnpm이 감지할 수 있는 레지스트리 수준의 신호가 없기 때문입니다. 또한 명시적으로 선언하면 잘못된 값이 조용한 오작동이 아니라 수정 가능한 설정 오류로 남습니다.

주의

serverType은 서버 운영자만 할 수 있는 서버에 대한 선언이며, lockfile은 이에 의존합니다. 생략된 tarball URL은 --frozen-lockfile 설치를 포함한 모든 설치에서 선언된 레이아웃을 사용해 다시 만들어집니다. Declare a layout the server actually serves, and expect a one-time lockfile diff after declaring one. URLs that pnpm can now rebuild disappear from the lockfile on the next install that writes it.

Tar registries#

Added in: v12.15.0

A tar registry serves each package as an uncompressed tar instead of a .tgz. The tar is the gzip-decoded content of the published .tgz, sent with HTTP content coding: zstd or gzip, as the request accepts. Its metadata pins the hash of the tar in dist.integrity, so the registry can compress the tar however it likes without changing any hash. pnpr exposes one with tarballs: tar.

A project uses a tar registry by keying its URL and declaring its layout:

pnpm-workspace.yaml
registries:
  https://pnpr.corp.example/npm/~zstd/:
    scopes: ["@"]
    serverType: pnpr

The server decides which base serves tars. In pnpr's example they are at /npm/~zstd/, next to the usual .tgz base, but a registry can serve tars from its main base too; see tar registries in pnpr. Declare serverType: pnpr on any pnpr registry base so pnpm omits canonical <name>@<version> tarball URLs from pnpm-lock.yaml.

pnpm tells a tar from a .tgz by the first bytes of the decoded response, so nothing else needs to be declared. The lockfile keeps its integrity field, which for packages from a tar registry holds the hash of the tar.

  • Switching a project between a .tgz registry and a tar registry changes what the registry serves, so the recorded hashes no longer match. Run pnpm install --update-checksums after the switch. A lockfile that pins tars with lockfile.integrityTarget: tar keeps every hash across the switch.
  • A missing hash. A tar registry that does not know a version's tar hash yet omits dist.integrity. pnpm then downloads the tarball during resolution and records the hash of the tar it received.
  • A proxy that rewrites Accept-Encoding, such as Cloudflare's edge in front of a Worker, can keep zstd from reaching the registry. The registry then sends the tar gzip-coded or uncompressed. The tar and its hash are the same either way, so installs are unaffected and only the download size changes. pnpr's Cloudflare guide shows how its Worker gets zstd through.
  • Size limits. pnpm checks a tarball's hash only after it decoded it, so it bounds what it decodes first. The files of one package may not exceed maxTarballUnpackedSize. The files of a tar may not exceed the package's dist.unpackedSize either. The headers and skipped entries of one archive may not exceed 256 MiB, and a zstd response may not use a window larger than 8 MiB.

supportsTimeField#

이 레지스트리의 축약 메타데이터에 time 필드가 포함되는지 여부입니다. registry.npmjs.org의 축약 메타데이터에는 이 필드가 없습니다. 그래서 기본값이 false이며, minimumReleaseAge와 같은 시간 기반 해석 기능은 훨씬 큰 전체 메타데이터 문서를 대신 사용합니다. A registry that does carry it (Verdaccio v5.15.1+ and several proxies) is worth declaring:

pnpm-workspace.yaml
registries:
  https://verdaccio.corp.example.com/:
    scopes: ["@"]
    supportsTimeField: true

이는 registrySupportsTimeField 설정의 레지스트리별 형태입니다. 대체 동작은 레지스트리별로 결정됩니다. 전체 메타데이터가 필요한 레지스트리가 하나 있더라도 다른 레지스트리에서는 더 이상 그 비용이 들지 않으며, 프로젝트가 설명하지 않은 모든 레지스트리에는 여전히 registrySupportsTimeField가 적용됩니다.

networkConcurrency#

Added in: v12.9.0

The most requests pnpm keeps in flight to this registry's origin (its scheme, host, and port) at once. Use it for a server that rate-limits or slows down under load, without lowering concurrency for every other registry:

pnpm-workspace.yaml
registries:
  https://npm.corp.example.com/:
    scopes: ["@acme"]
    networkConcurrency: 4

The limit applies to every request whose URL is on the entry's origin, including tarballs the registry serves from the same origin. A request that reaches the origin through a redirect from another one counts against the origin it was sent to. Requests still count against the overall networkConcurrency, so a value above it has no effect. Entries whose URLs share an origin share the smallest of their limits. An entry may set only networkConcurrency, for example to limit the default registry or a host that serves tarballs.

If a request to the origin times out while other requests to it are still running, pnpm lowers its limit to one request for the rest of the command, as it does for origins without an entry. The value must be a positive integer. Unlike the npm-specific fields, it is accepted for Cargo and PyPI entries too.

ecosystem#

Added in: v12.5.0

Select which package ecosystem the registry serves: npm (the default), cargo, or pypi.

pnpm-workspace.yaml
registries:
  https://internal.example/simple/:
    ecosystem: pypi
    packages: ["company-*"]
  https://pypi.org/simple/:
    ecosystem: pypi
    packages: ["*"]
  https://index.crates.io/:
    ecosystem: cargo

Since v12.5.1, a Python package resolves exclusively from the index claiming its name through packages. Declaration order has no effect, and a missing package or registry failure never falls back to another index. (v12.5.0 instead searched the indexes in declaration order.) Cargo accepts one sparse index. With no declaration for an ecosystem, pnpm uses PyPI or crates.io. Since v12.5.0, this replaces the removed python.indexUrl, python.extraIndexUrls, and cargo.indexUrl settings.

Credentials cannot appear in the URL key. Configure them in .npmrc; they are matched by origin for all ecosystems. The npm-specific fields scopes, prefix, serverType, and supportsTimeField are refused for Cargo and PyPI entries.

packages#

Added in: v12.5.1

For ecosystem: pypi, the distribution names this index serves. An npm or Cargo entry that sets packages is refused rather than silently ignored.

A pattern is an exact name such as torch, a name prefix followed by a single * such as company-*, or * (equivalently **) for the default index. Names are compared after Python name normalization: case is ignored and runs of ., _, and - collapse to -, so Company_Tools and company-tools are one claim. Any other wildcard shape, such as company-** or @scope/*, is rejected, as is an empty list.

Exact names and prefixes take precedence over the default index; among themselves they never compete, because two patterns that can match the same name are refused with ERR_PNPM_INVALID_SETTING. That holds both across entries and inside one entry, so an entry claiming the default may claim nothing else, and only one index may be the default.

The claiming index serves direct, transitive, and isolated build dependencies alike. A missing package, an incompatible version, an authentication error, or any other registry failure stops resolution; pnpm never retries another index.

Omitting packages claims the default too, so a single custom Python index needs no patterns, and two indexes that both omit it are refused as two defaults. Once any Python index is declared, PyPI is not added implicitly: a package no index claims fails with ERR_PNPM_UNCLAIMED_PYTHON_PACKAGE unless one index is the default. Changing the routes invalidates Python lockfiles.

See Python indexes for an example with private packages and a PyPI default.

설정을 둘 수 있는 위치#

The server descriptions (serverType and supportsTimeField) are read only from pnpm-workspace.yaml, because the lockfile depends on them: one developer omitting tarball URLs that another reconstructs differently would break a frozen install.

The global configuration file (config.yaml) may declare ecosystem indexes, the routes (scopes and prefix) so that a scope or an alias like work: applies to every project on the machine, and networkConcurrency, which does not affect the lockfile.

Since v12.1.0, pnpm login --scope <scope> adds that machine-wide scope route to the global registries setting. A later login for the same scope moves the route rather than declaring it at two registries.

Since v12.4.0, a registry configured in .npmrc outranks a route pnpm login saved in the global config.yaml, so logging in cannot redirect a project that names its registry explicitly.

An npm entry that declares no routes describes a registry configured elsewhere. For example, the default registry set in .npmrc. 이러한 항목은 해당 URL이 프로젝트가 실제로 해석에 사용하는 레지스트리일 때만 적용됩니다. 설정된 어떤 레지스트리와도 일치하지 않는 항목은 아무 효과 없이 남아 있게 되므로 pnpm이 경고합니다(오래된 URL, 이동된 스코프).

이 설정의 URL 키에서는 환경 변수가 확장되지 않습니다. 이는 다른 pnpm-workspace.yaml의 레지스트리 URL에서 확장되지 않는 것과 같은 이유입니다. 이 파일은 커밋되며, 환경 변수를 요청 대상으로 확장하면 공격자가 제어하는 호스트로 비밀 정보가 유출될 수 있습니다. A key containing a ${...} placeholder fails the command.

이전 형식#

The older shape of registries maps scopes to URLs, with the default key naming the main registry:

pnpm-workspace.yaml
registries:
  default: https://registry.npmjs.org/
  "@acme": https://npm.corp.example.com/

이 형식은 여전히 허용되며 이전과 같이 동작합니다. 두 형식은 하나의 맵에서 혼용할 수 없습니다. An entry whose value is a string is a scope route, and a scope route keyed by a URL is an error.

namedRegistries 설정은 사용 중단되었으며 prefix로 대체되었습니다. 이 설정은 여전히 읽히지만 registries가 선언하지 않은 접두사에 대해서만 적용되며, 둘 다 접두사를 선언하면 pnpm이 경고합니다.