Перейти до основного змісту
Версія: Next

Сценарії

Як pnpm обробляє поле scripts для package.json.

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)

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.

Сценарії життєвого циклу

pnpm:devPreinstall

Виконуються лише через локальний pnpm install.

Запускається до встановлення будь-якої залежності.

Цей сценарій виконується, лише якщо встановлено package.json в корені проєкту.