pnpm CLI
짧은 별칭#
pn은 pnpm의 짧은 별칭으로, pnx는 pnpm dlx의 짧은 별칭으로 사용할 수 있습니다. pnpm 또는 pnpx를 사용하는 모든 곳에서 이를 사용할 수 있습니다:
pn install
pn add express
pn build
pn test
pnx create-vue my-app
npm과의 차이점#
npm과 달리 pnpm은 모든 옵션의 유효성을 검사합니다. 예를 들어, --target_arch는 pnpm install의 유효한 옵션이 아니므로 pnpm install --target_arch x64는 실패합니다.
Some dependencies read an npm_config_ environment variable during their build.
pnpm does not set these variables from its options, so set the variable yourself:
npm_config_target_arch=x64 pnpm install.
Boolean flags#
A boolean flag can be written on its own, negated with a no- prefix, or given an explicit value:
pnpm install --prod # devDependencies are skipped
pnpm install --no-prod # devDependencies are installed
pnpm install --prod=false # the same, since v12.4.0
pnpm install --prod=true # the same as --prod
The --config. escape hatch takes a value the same way: --config.trust-lockfile=false.
Which project a command acts on#
Run from a subdirectory of a project, a command acts on the nearest ancestor
directory that has a manifest, so pnpm bin from packages/app/src reports
paths under packages/app. Two commands stay where you are: pnpm init
creates its manifest in the current directory, and pnpm exec runs the command
there.
옵션#
-C <path>, --dir <path>#
현재 작업 디렉터리 대신 <path>에서 pnpm을 시작한 것처럼 실행합니다.
-w, --workspace-root#
현재 작업 디렉터리 대신 워크스페이스의 루트에서 pnpm을 시작한 것처럼 실행합니다.
--ignore-workspace#
Run as if the current project were standalone. pnpm does not discover a
pnpm-workspace.yaml in a parent directory, so the workspace's settings and
other projects do not apply to the command.
For example, this installs only the project in the current directory, even if it is located inside a workspace:
pnpm install --ignore-workspace
--workspace-packages <glob>#
Select the workspace's projects with a glob pattern, overriding the
packages field of pnpm-workspace.yaml. Repeat
the flag to add more patterns.
-y, --yes#
Automatically answer yes to prompts.
--env-file <path>#
Added in: v12.16.0
Load environment variables from a dotenv-style file before running. Repeat the flag to layer more files:
pnpm --env-file .env run build
pnpm --env-file .env --env-file .env.local install
Later files override variables defined in earlier files, and variables
already in the environment are never overridden. Relative paths resolve
against the working directory where pnpm was invoked. The loaded variables
are visible to config resolution (PNPM_CONFIG_<KEY> overrides and ${VAR}
tokens in user-level .npmrc files, so registry tokens can
live in the env file instead of the shell), to lifecycle scripts, and to any
pnpm the command dispatches to.
The files are read the way node --env-file reads them. Values are taken
as written, and $VAR is not expanded. A leading UTF-8 byte-order mark is
ignored. A missing file fails the command.
The flag is pnpm's own: a shim invocation forwards its arguments to the shim target untouched and never loads env files.
Commands#
자세한 내용은 각각의 CLI commands 문서를 참고하십시오. 다음 목록은 npm 커맨드와의 간단한 비교입니다.
| npm | pnpm |
|---|---|
npm install |
pnpm install |
npm i <pkg> |
pnpm add <pkg> |
npm run <cmd> |
pnpm <cmd> |
npx <pkg> |
pnx <pkg> |
알 수 없는 명령을 사용하면 pnpm은 해당 이름의 스크립트를 찾으므로, pnpm run lint는 pnpm lint와 같습니다. 지정한 이름의 스크립트가 없으면 pnpm은 명령을 셸 스크립트로 실행하므로, pnpm eslint와 같이 사용할 수 있습니다(pnpm exec 참조).
환경 변수#
pnpm과 관련되지 않은 일부 환경 변수는 pnpm의 동작을 변경할 수 있습니다.
CINO_COLORturns off colored output.
These environment variables configure pnpm itself:
pnpm_config_<setting>sets a setting. See Environment variables.PNPM_HOMEsets the pnpm home directory, which holds global packages, their bins, and the default store.PNPM_SHIM_BYPASS=1makes a global shim run its global target and ignore the project's pin. See project-aware global bins.
이러한 환경 변수는 pnpm이 전역 정보를 저장하기 위해 사용하는 디렉토리에 영향을 줄 수 있습니다.
XDG_CACHE_HOMEXDG_CONFIG_HOMEXDG_DATA_HOMEXDG_STATE_HOME
You can search the docs to find the settings that use these environment variables.