본문으로 건너뛰기
버전: Next

스크립트

pnpm이 package.jsonscripts 필드를 처리하는 방법.

Hidden Scripts

Added in: v11.0.0

Scripts with names starting with . are hidden. They cannot be run directly via pnpm run and are omitted from the pnpm run listing. Hidden scripts can only be called from other scripts.

{
"scripts": {
".helper": "echo 'I am hidden'",
"build": "pnpm run .helper && tsc"
}
}

In this example, pnpm run .helper would fail, but pnpm run build would succeed because .helper is called from another script.

Environment Variables

pnpm sets the following environment variables during lifecycle script execution:

  • npm_package_name — the package name
  • npm_package_version — the package version
  • npm_lifecycle_event — the name of the running script (e.g., postinstall)
note

Since v11, pnpm no longer populates npm_config_* environment variables from the pnpm configuration. Only the well-known npm_* variables above are set, matching Yarn's behavior.

Built-in Command and Script Name Conflicts

Added in: v11.0.0

The following built-in commands prefer user scripts: clean, setup, deploy, and rebuild. If your package.json defines a script with one of these names, pnpm <name> will execute the script instead of the built-in command.

To force the built-in command, use pnpm pm <name>.

라이프사이클 스크립트

pnpm:devPreinstall

로컬 pnpm install에서만 실행됩니다.

의존성이 설치되기 전에 실행됩니다.

이 스크립트는 루트 프로젝트의 package.json에 설정된 경우에만 실행됩니다.