pnpm deploy
워크스페이스에서 패키지를 배포합니다. 배포 중에 배포된 패키지의 파일이 대상 디렉터리에 복사됩니다. 워크스페이스의 종속성을 포함하여 배포된 패키지의 모든 종속성은 대상 디렉터리의 격리된 node_modules 디렉터리 내에 설치됩니다. 대상 디렉터리에는 추가 단계 없이 서버에 복사하고 실행할 수 있는 이식 가능한 패키지가 포함됩니다.
참고
Since v11.26.0, pnpm deploy no longer requires injectWorkspacePackages. A linked workspace dependency is rewritten to a file: dependency in the dedicated deploy lockfile. The peer dependencies it declares are bound the way an injected install binds them: to the version its parent provides. If the parent does not depend on the peer, pnpm looks further up, to the deployed project. A peer that no ancestor provides is bound to the deployed graph's own resolution. This includes optional peers declared only in peerDependenciesMeta.
The binding is ambiguous when the ancestors provide more than one package or version, or when no ancestor provides the peer and the deployed graph holds more than one version. The deploy then fails with ERR_PNPM_DEPLOY_AMBIGUOUS_PEER, naming the package, the peer, and the competing resolutions. Pin the peer to one version with an overrides entry, or turn injectWorkspacePackages on, which is the setting that decides between the candidates.
Before v11.26.0 the command refused every non-injected workspace up front. --legacy, or forceLegacyDeploy: true, still selects the older implementation.
참고
enableGlobalVirtualStore 옵션이 설정되어 있어도 pnpm deploy는 이를 무시하고 항상 배포 디렉터리 내에 로컬 가상 스토어를 생성합니다. 이렇게 하면 배포 디렉터리가 자체적으로 완결되고 이식 가능한 상태로 유지됩니다.
사용법:
pnpm --filter=<deployed project name> deploy <target directory>
배포 전에 프로젝트를 빌드하는 경우, --prod 옵션을 사용하여 devDependencies 설치를 건너뜁니다.
pnpm --filter=<deployed project name> --prod deploy <target directory>
도커 이미지에서의 사용. 모노레포에서 모든 것을 빌드한 후 모노레포 기본 이미지를 빌드 컨텍스트로 사용하는 두 번째 이미지 또는 추가 빌드 단계에서 이 작업을 수행하세요.
# syntax=docker/dockerfile:1.4
FROM workspace as pruned
RUN pnpm --filter <your package name> --prod deploy pruned
FROM node:22-alpine
WORKDIR /app
ENV NODE_ENV=production
COPY --from=pruned /app/pruned .
ENTRYPOINT ["node", "index.js"]
A deployed symlink to a directory inside the project is kept even if the directory is not deployed. So is a symlink to a missing path inside the project, such as a link into a removed node_modules. A link into node_modules resolves to the dependency installed in the output directory. A symlink to a file that is not deployed is replaced by a copy of the file.
To deploy without registry metadata, keep the source lockfile and populate the
store with pnpm install or pnpm fetch before running pnpm deploy --offline.
This also works with per-project lockfiles and --legacy. Use --trust-lockfile
if deployment should skip supply-chain policy checks on the locked dependencies.
New or changed dependencies may still require registry metadata.
옵션#
--force#
Allow deployment to a non-empty target directory. Without this flag, pnpm fails
with ERR_PNPM_DEPLOY_DIR_NOT_EMPTY if the target directory is not empty.
--ignore-scripts#
Skip lifecycle scripts during deployment, including dependency build scripts.
See pnpm install --ignore-scripts.
--dev, -D#
devDependencies만 설치됩니다.
--no-optional#
optionalDependencies는 설치되지 않습니다.
--prod, -P#
devDependencies의 패키지는 설치되지 않습니다.
--filter <package_selector>#
--legacy#
레거시 배포 구현을 강제로 사용합니다.
기본적으로 pnpm deploy는 배포를 위해 공유 lockfile로부터 전용 lockfile을 생성하려고 시도합니다. --legacy 플래그는 이 동작을 비활성화하며, inject-workspace-packages=true 설정 없이도 deploy 명령을 사용할 수 있게 합니다.
배포된 프로젝트에 포함된 파일#
By default, pnpm copies the files that pnpm pack would include. They are selected in one of the following ways, resolved in order:
- 프로젝트의
package.json에는 복사해야 하는 파일과 디렉터리가 나열된files필드가 포함될 수 있습니다. - 애플리케이션 디렉터리에
.npmignore파일이 있으면, 이 파일에 나열된 모든 파일이 무시됩니다. - 애플리케이션 디렉터리에
.gitignore파일이 있으면, 이 파일에 나열된 모든 파일이 무시됩니다.
To copy every file of the project, set deployAllFiles to true.
Since v11.28.0, symlinks that point to files or directories included in the deployed project are kept as symlinks.
The deployed project#
Since v11.28.0:
- The
packageManageranddevEngines.packageManagerfields of the workspace rootpackage.jsonare not copied into the deployedpackage.json. Versions v11.28.0 through v11.28.x copied them. - The virtual store is created at
virtualStoreDir, resolved against the deploy directory. A deploy from a shared lockfile recordsvirtualStoreDirin the deployedpnpm-workspace.yaml. With the global virtual store enabled or an absolutevirtualStoreDir, the deploy usesnode_modules/.pnpm. - The
preparescript of the deployed project is not run. --package-import-methodpassed on the command line is respected.
Since v11.28.12, a workspace project that the deploy installs as a file: dependency runs its build scripts. pnpm approves it by its dependency path in the allowBuilds setting. An allowBuilds entry that denies the project still applies. A project with publishConfig.directory is installed from that directory, and its build scripts run only if the directory is inside the project and not inside node_modules.
환경설정#
forceLegacyDeploy#
- 기본값: false
- 유형: Boolean
기본적으로 pnpm deploy는 배포를 위해 공유 lockfile로부터 전용 lockfile을 생성하려고 시도합니다. 이 설정을 true로 지정하면 레거시 deploy 동작이 사용됩니다.