pnpm patch <pkg>

패칭을 위한 패키지를 준비합니다(Yarn의 유사한 명령에서 영감을 받음).

This command extracts the package to node_modules/.pnpm_patches/<pkg>, where <pkg> is the argument as given, such as foo or foo@1.0.0 (or the --edit-dir), a directory you can edit at will.

Once you're done with your changes, run pnpm patch-commit <path> (with <path> being the directory you received) to generate a patchfile and register it into your top-level manifest via the patchedDependencies field.

사용법:

pnpm patch <pkg name>@<version>

참고

To change a package's dependencies, don't use pnpm patch to modify its package.json! Use overrides or a package hook instead.

옵션#

--edit-dir <dir>#

패치가 필요한 패키지는 이 디렉터리로 추출됩니다.

--ignore-existing#

패치할 때 기존에 존재하는 패치 파일을 무시합니다.

환경설정#

patchedDependencies#

이 필드는 pnpm patch-commit을 실행하면 자동으로 추가/업데이트됩니다. 다음과 같은 딕셔너리를 사용하여 종속성에 대한 패치를 정의합니다:

  • 키: 정확한 버전, 버전 범위 또는 이름만 포함한 패키지 이름입니다.
  • 값: 패치 파일의 상대 경로입니다.

예시:

pnpm-workspace.yaml
patchedDependencies:
  express@4.18.1: patches/express@4.18.1.patch

종속성은 버전 범위로 패치할 수 있습니다. 우선순위는 다음과 같습니다:

  1. 정확한 버전(가장 높은 우선순위)
  2. 버전 범위
  3. 이름만 지정한 패치(재정의하지 않는 한 모든 버전에 적용됨)

예시:

pnpm-workspace.yaml
patchedDependencies:
  foo: patches/foo-1.patch
  foo@^2.0.0: patches/foo-2.patch
  foo@2.1.0: patches/foo-3.patch
  • patches/foo-3.patch는 foo@2.1.0에 적용됩니다.
  • patches/foo-2.patch는 2.1.0을 제외하고 ^2.0.0과 일치하는 모든 foo 버전에 적용됩니다.
  • patches/foo-1.patch는 그 외의 모든 foo 버전에 적용됩니다.

겹치는 버전 범위는 피하세요. 하위 범위를 특수하게 처리해야 한다면 더 넓은 범위에서 명시적으로 제외하세요.

예시:

pnpm-workspace.yaml
patchedDependencies:
  # Specialized sub-range
  "foo@2.2.0-2.8.0": patches/foo.2.2.0-2.8.0.patch
  # General patch, excluding the sub-range above
  "foo@>=2.0.0 <2.2.0 || >2.8.0": patches/foo.gte2.patch

대부분의 경우 정확한 버전을 정의하는 것만으로 더 넓은 범위를 재정의하기에 충분합니다.

allowUnusedPatches#

추가된 버전: v10.7.0 (이전 이름: allowNonAppliedPatches)

  • 기본값: false
  • 유형: Boolean

true인 경우, patchedDependencies 필드의 일부 패치가 적용되지 않더라도 설치가 실패하지 않습니다.

pnpm-workspace.yaml
patchedDependencies:
  express@4.18.1: patches/express@4.18.1.patch
allowUnusedPatches: true

참고

In v11, patch application failures always throw an error. The ignorePatchFailures setting has been removed. When multiple patches in a group are applied, a failure in one does not prevent the rest from being attempted; all patch errors are reported together at the end.