지원되는 패키지 소스

pnpm은 다양한 소스에서 패키지를 설치하는 것을 지원합니다. 이러한 소스는 신뢰할 수 있는 소스와 특이한 소스의 두 가지 범주로 나뉩니다.

특이한 소스(Git 저장소나 직접 tarball URL 등)는 전이 종속성에서 사용될 때 공급망 위험을 초래할 수 있습니다. blockExoticSubdeps를 true로 설정하면 전이 종속성이 특이한 소스를 사용하지 못하도록 막을 수 있습니다.

신뢰할 수 있는 소스#

신뢰할 수 있는 소스는 직접 종속성과 전이 종속성 모두에 안전한 것으로 간주됩니다.

npm 레지스트리#

pnpm add package-name은 기본적으로 npm 레지스트리에서 package-name의 최신 버전을 설치합니다.

워크스페이스에서 실행하는 경우, 명령은 먼저 워크스페이스에 있는 다른 프로젝트가 지정된 패키지를 사용하는지 여부를 확인합니다. 이 경우, 이미 사용된 버전이 설치됩니다.

다음을 통해 패키지를 설치할 수도 있습니다.

  • 태그: pnpm add express@nightly
  • 버전: pnpm add express@1.0.0
  • 버전 범위: pnpm add express@2 react@">=0.1.0 <0.2.0"

JSR 레지스트리#

JSR 레지스트리에서 패키지를 설치하려면 jsr: 프로토콜 접두사를 사용하세요:

pnpm add jsr:@hono/hono
pnpm add jsr:@hono/hono@4
pnpm add jsr:@hono/hono@latest

이것은 npm에서 설치하는 것과 동일하게 작동하지만 JSR을 통해 패키지를 확인하도록 pnpm에 지시합니다.

crates.io and PyPI#

Added in: v12.4.0 (pnpm v12 only)

A crate: or pypi: prefix asks for a package of another ecosystem, once that ecosystem is enabled in pnpm-workspace.yaml:

pnpm add crate:serde
pnpm add pypi:httpx

Such a dependency is recorded in that ecosystem's own manifest and lockfile, not in package.json or pnpm-lock.yaml. See Cargo dependencies and Python dependencies.

Provisioned tools#

Added in: v12.13.0 (pnpm v12 only)

The tool: protocol asks for a tool pnpm downloads from the tool's own releases instead of from npm: Node.js, Bun, Deno, and Yarn.

pnpm add node@tool:24
pnpm add bun@tool:1.3.0
pnx node@tool:22 --version
pnx yarn@tool:4 --version

yarn@tool:<version> picks Yarn from wherever that line is published, like yarn@<version> does.

runtime: is an alias of tool: and keeps working everywhere it worked before. pnpm-lock.yaml still records these entries with runtime:, such as node@runtime:24.6.0, so lockfiles stay readable by earlier pnpm versions.

이름이 지정된 레지스트리#

이름이 지정된 레지스트리 별칭은 기본 레지스트리와 관계없이 특정 레지스트리에서 패키지를 해석합니다:

pnpm add work:@corp/lib@^2.0.0
pnpm add gh:@my-org/private-pkg
pnpm add npmjs:left-pad

gh: (GitHub Packages) and npmjs: (the public npm registry) work without configuration. Any other alias must be mapped under namedRegistries in pnpm-workspace.yaml or in the global configuration file (config.yaml).

작업 공간#

When adding dependencies and working within a workspace, packages will be installed from the configured sources, depending on whether or not linkWorkspacePackages is set, and use of the workspace: range protocol.

로컬 파일 시스템#

로컬 파일 시스템에서 설치하는 방법에는 두 가지가 있습니다.

  1. tarball 파일(.tar, .tar.gz 또는 .tgz)에서
  2. 디렉토리에서 설치

예시:

pnpm add ./package.tar.gz
pnpm add ./some-directory

pnpm add ./some-directory records the dependency with the link: protocol. pnpm creates a symlink in the current project's node_modules, so it is the same as running pnpm link.

To install a directory as a package instead, use the file: protocol, for example pnpm add file:./some-directory. pnpm copies the directory into the virtual store and installs its dependencies.

특이한 소스#

특이한 소스는 개발에 유용하지만 전이 종속성에서 사용될 때 공급망 위험을 초래할 수 있습니다.

원격 tarball#

pnpm sends registry credentials for tarball downloads over HTTPS or loopback HTTP. A redirect receives credentials only within the configured registry path on the same origin.

인수는 "http://" 또는 "https://"로 시작하는 가져올 수 있는 URL이어야 합니다.

예시:

pnpm add https://github.com/indexzero/forever/tarball/v0.5.6

Git 저장소#

pnpm add <git remote url>

지정된 URL의 Git 저장소에서 패키지를 설치합니다. Depending on the repository, pnpm either downloads a source archive from the Git host or clones the repository with Git. See how Git dependencies are resolved.

다음을 통해 Git에서 패키지를 설치할 수 있습니다:

  • 기본 브랜치의 최신 커밋:
pnpm add kevva/is-positive
  • Git 커밋 해시:
pnpm add kevva/is-positive#97edff6f525f192a3f83cea1944765f769ae2678
  • Git 브랜치:
pnpm add kevva/is-positive#master
  • 깃 브랜치 참조:
pnpm add zkochan/is-negative#heads/canary
  • 깃 태그:
pnpm add zkochan/is-negative#2.0.1
  • V-접두사가 붙은 Git 태그:
pnpm add andreineculau/npm-publish-git#v0.0.7

시맨틱 버전을 사용하여 Git 저장소로부터 설치#

semver: 매개변수를 사용하여 설치할 버전(범위)을 지정할 수 있습니다. 예시:

  • 엄격한 semver:
pnpm add zkochan/is-negative#semver:1.0.0
  • V-접두사가 붙은 엄격한 semver:
pnpm add andreineculau/npm-publish-git#semver:v0.0.7
  • Semver 범위를 통한 설치:
pnpm add kevva/is-positive#semver:^2.0.0
  • V-접두사가 붙은 semver 버전 범위:
pnpm add andreineculau/npm-publish-git#semver:<=v0.0.7

Git 저장소의 하위 디렉터리에서 설치하기#

path: 매개변수를 사용하여 Git에 호스팅된 모노레포에서 하위 디렉터리만 설치할 수도 있습니다. 예를 들어:

pnpm add RexSkz/test-git-subfolder-fetch#path:/packages/simple-react-app

전체 URL을 통해 Git 저장소에서 설치하기#

더 명시적으로 지정하고 싶거나 다른 Git 호스팅을 사용하는 경우, 전체 Git URL을 작성할 수 있습니다:

# git+ssh
pnpm add git+ssh://git@github.com:zkochan/is-negative.git#2.0.1

# https
pnpm add https://github.com/zkochan/is-negative.git#2.0.1

호스팅 제공자 약어를 사용하여 Git 저장소에서 설치하기#

특정 Git 제공자에 대해 프로토콜 약어 [provider]:를 사용할 수 있습니다:

pnpm add github:zkochan/is-negative
pnpm add bitbucket:pnpmjs/git-resolver
pnpm add gitlab:pnpm/git-resolver
pnpm add gist:106cfef49f8476b753a9cbbf9c65aff1

[provider]:를 생략하면 기본값은 github:입니다.

여러 매개변수를 결합하여 Git 저장소에서 설치#

여러 매개변수를 &로 구분하여 결합할 수 있습니다. 이는 모노레포를 포크(fork)한 경우에 유용할 수 있습니다:

pnpm add RexSkz/test-git-subdir-fetch.git#beta\&path:/packages/simple-react-app

beta 브랜치에서 /packages/simple-react-app에 있는 하위 디렉터리만 설치합니다.

pnpm also accepts npm's syntax, which separates the parameters with :::

pnpm add RexSkz/test-git-subdir-fetch.git#beta::path:packages/simple-react-app

Git 종속성이 해석되는 방식#

추가된 버전: v12.0.0 (pnpm v12 전용)

For repositories on GitHub, GitLab, Bitbucket, and GitHub Gist, the specifier is an identity, not a choice of transport. 다음은 모두 같은 종속성을 가리키며 동일하게 해석됩니다:

kevva/is-positive
github:kevva/is-positive
git+https://github.com/kevva/is-positive.git
https://github.com/kevva/is-positive.git
git+ssh://git@github.com/kevva/is-positive.git

각각은 호스트의 표준 HTTPS URL을 통해 해석되며, lockfile에는 다음 두 가지 형태 중 하나가 기록됩니다:

  • 호스트의 소스 아카이브, 즉 일반 tarball 다운로드. 이는 해당 아카이브 URL에 대한 익명 요청이 성공한 경우에만 기록되므로, 기록된 아카이브 URL은 구조적으로 항상 가져올 수 있습니다.
  • 그렇지 않으면 표준 HTTPS URL을 통한 git 해석이 기록되며, 저장소에 접근할 수 있는 모든 머신에서 이를 가져올 수 있습니다.

pnpm은 이러한 호스트에 대해 SSH URL을 기록하지 않습니다. 특정 머신이 호스트에 접근할 때 사용하는 전송 방식은 프로젝트의 속성이 아니라 해당 머신의 Git 설정에 따라 결정됩니다.

비공개 저장소에 SSH 사용하기#

Git 자체에서, 해당 머신에 재작성 규칙을 설정하세요:

git config --global url."git@github.com:".insteadOf https://github.com/

pnpm은 git을 호출하므로 이 재작성은 pnpm의 모든 Git 작업에 자동으로 적용됩니다. The same holds on CI: give the runner an SSH key and this rewrite, or an HTTPS credential helper. The lockfile is identical either way.

다른 호스트의 저장소#

A URL that does not point at a known host (a self-hosted GitLab, Gitea, or any internal Git server) is kept exactly as written, transport included. For those, the URL is the identity. 자격 증명이 포함된 URL도 그대로 유지되며, 호스트 아카이브로 해석되지 않습니다.

정보

Existing lockfile entries are left untouched. The rules above apply when an entry is added or re-resolved, and pnpm update <package> re-records an SSH URL over HTTPS.

Git 종속성이 빌드되는 방식#

추가된 버전: v12.0.0-rc.6 (pnpm v12 전용)

A Git-hosted dependency that ships sources rather than a built package has to be prepared (its dependencies installed and its build script run) before it can be installed. pnpm prepares it with the package manager the dependency asks for. See Preparing a git-hosted dependency.