# @pnpm/lifecycle

> Package lifecycle hook runner

Latest version **1001.0.37** (published 2026-03-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @pnpm/lifecycle
pnpm add @pnpm/lifecycle
yarn add @pnpm/lifecycle
bun add @pnpm/lifecycle
```

## Health

**Score 65/100 (B)** — status: stable.

Positive: has types; esm support; no vulnerabilities; has provenance; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1001.0.37 |
| Published | 2026-03-24 |
| First published | 2018-03-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18.12 |
| Dependencies | 12 |
| Unpacked size | 28.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| Maintainers | pnpmuser, zkochan |
| Keywords | pnpm, pnpm10, lifecycle, scripts |

## Links

- npm: https://www.npmjs.com/package/@pnpm/lifecycle
- Repository: https://github.com/pnpm/pnpm.git#main
- Homepage: https://github.com/pnpm/pnpm/tree/main/exec/lifecycle#readme
- Issues: https://github.com/pnpm/pnpm/issues
- Funding: https://opencollective.com/pnpm
- npm.io page: https://npm.io/package/@pnpm/lifecycle

## Dependencies (12)

- [shlex](https://npm.io/package/shlex.md) ^2.1.2
- [is-windows](https://npm.io/package/is-windows.md) ^1.0.2
- [run-groups](https://npm.io/package/run-groups.md) ^3.0.1
- [@pnpm/error](https://npm.io/package/@pnpm/error.md) 1000.1.0
- [@pnpm/types](https://npm.io/package/@pnpm/types.md) 1001.3.0
- [path-exists](https://npm.io/package/path-exists.md) ^4.0.0
- [@pnpm/link-bins](https://npm.io/package/@pnpm/link-bins.md) 1000.3.8
- [@pnpm/core-loggers](https://npm.io/package/@pnpm/core-loggers.md) 1001.0.9
- [@pnpm/npm-lifecycle](https://npm.io/package/@pnpm/npm-lifecycle.md) ^1001.0.0
- [@pnpm/directory-fetcher](https://npm.io/package/@pnpm/directory-fetcher.md) 1000.1.24
- [@pnpm/read-package-json](https://npm.io/package/@pnpm/read-package-json.md) 1000.1.8
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) 1004.5.1

## Recent versions

- 1001.0.37 (latest) — 2026-03-24
- 1001.0.39 (latest-10) — 2026-06-10
- 900.0.4 (latest-9) — 2025-02-02
- 0.0.0-20230605-20230605142810 (dev) — 2023-06-05
- 12.1.10 (latest-6) — 2022-07-05
- 9.2.2 (pnpm-temp) — 2020-07-31
- 8.1.1 (next) — 2020-04-05
- 1001.0.38 — 2026-05-06
- 1001.0.36 — 2026-02-23
- 1001.0.35 — 2026-02-17
- 1001.0.34 — 2026-01-26
- 1001.0.33 — 2026-01-19
- 1001.0.32 — 2025-12-30
- 1001.0.31 — 2025-12-23
- 1001.0.30 — 2025-12-15
- … 187 more at https://npm.io/package/@pnpm/lifecycle/versions

## README

# @pnpm/lifecycle

> Package lifecycle hook runner

<!--@shields('npm')-->
[![npm version](https://img.shields.io/npm/v/@pnpm/lifecycle.svg)](https://www.npmjs.com/package/@pnpm/lifecycle)
<!--/@-->

## Installation

```sh
pnpm add @pnpm/logger @pnpm/lifecycle
```

## Usage

```ts
import runLifecycleHook, {runPostinstallHooks} from '@pnpm/lifecycle'

const targetPkgRoot = path.resolve('node_modules/target-pkg')
const pkg = require(path.join(targetPkgRoot, 'package.json'))

// Run a specific hook
await runLifecycleHook('preinstall', pkg, {
  pkgId: 'target-pkg/1.0.0',
  pkgRoot: targetPkgRoot,
  rawConfig: {},
  rootModulesDir: path.resolve('node_modules'),
  unsafePerm: true,
})

// Run all install hooks
await runPostinstallHooks({
  pkgId: 'target-pkg/1.0.0',
  pkgRoot: targetPkgRoot,
  rawConfig: {},
  rootModulesDir: path.resolve('node_modules'),
  unsafePerm: true,
})
```

## API

### `runLifecycleHook(stage, packageManifest, opts): Promise<void>`

### `runPostinstallHooks(opts): Promise<void>`

## License

MIT

---
_Source: https://npm.io/package/@pnpm/lifecycle · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
