본문으로 건너뛰기
버전: 9.x

pnpm add <pkg>

패키지와 패키지가 의존하는 모든 패키지를 설치합니다. 기본적으로 새 패키지는 프로덕션 의존성으로 설치됩니다.

요약

명령어의미
pnpm add saxSave to dependencies
pnpm add -D saxSave to devDependencies
pnpm add -O saxSave to optionalDependencies
pnpm add -g sax 패키지를 전역으로 설치합니다
pnpm add sax@nextInstall from the next tag
pnpm add sax@3.0.0Specify version 3.0.0

지원되는 패키지 위치

npm 레지스트리에서 설치

pnpm add package-name will install the latest version of package-name from the npm registry by default.

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

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

  • tag: pnpm add express@nightly
  • version: pnpm add express@1.0.0
  • version range: pnpm add express@2 react@">=0.1.0 <0.2.0"

워크스페이스에서 설치하기

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

로컬 파일 시스템에서 설치

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

  1. from a tarball file (.tar, .tar.gz, or .tgz)
  2. 디렉토리에서 설치

예시:

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

When you install from a directory, a symlink will be created in the current project's node_modules, so it is the same as running pnpm link.

원격 타르볼에서 설치

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

예시:

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

Git 저장소에서 설치

pnpm add <git remote url>

호스트된 Git 공급자로부터 패키지를 설치하여 Git으로 복제합니다. 여러분은 특정 Git 공급자에 대한 프로토콜을 사용할 수 있습니다. For example, pnpm add github:user/repo

다음과 같이 Git 에서 설치할 수 있다.

  • latest commit from master: pnpm add kevva/is-positive
  • commit: pnpm add kevva/is-positive#97edff6f525f192a3f83cea1944765f769ae2678
  • branch: pnpm add kevva/is-positive#master
  • version range: pnpm add kevva/is-positive#semver:^2.0.0

옵션

--save-prod, -P

Install the specified packages as regular dependencies.

--save-dev, -D

Install the specified packages as devDependencies.

--save-optional, -O

Install the specified packages as optionalDependencies.

--save-exact, -E

저장된 의존성은 pnpm의 기본 semver 범위 연산자를 사용하지 않고 정확한 버전으로 구성됩니다.

--save-peer

Using --save-peer will add one or more packages to peerDependencies and install them as dev dependencies.

--ignore-workspace-root-check

Adding a new dependency to the root workspace package fails, unless the --ignore-workspace-root-check or -w flag is used.

For instance, pnpm add debug -w.

--global, -g

패키지를 전역으로 설치합니다.

--workspace

워크스페이스에서 발견된 경우에만 새 의존성을 추가합니다.

--filter &lt;package_selector>

Read more about filtering.