# preferred-pm

> Detects what package manager was used for installation

Latest version **5.0.0** (published 2026-03-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install preferred-pm
pnpm add preferred-pm
yarn add preferred-pm
bun add preferred-pm
```

## Health

**Score 63/100 (C)** — status: stable.

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2026-03-11 |
| First published | 2018-03-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/preferred-pm) |
| Module format | ESM + CommonJS |
| Node | >=22.13 |
| Dependencies | 3 |
| Unpacked size | 4.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 104 |
| Author | Zoltan Kochan |
| Maintainers | zkochan |
| Keywords | npm, pnpm, yarn |

## Links

- npm: https://www.npmjs.com/package/preferred-pm
- Repository: https://github.com/zkochan/packages/tree/main/preferred-pm
- Issues: https://github.com/zkochan/packages/labels/package%3A%20preferred-pm
- npm.io page: https://npm.io/package/preferred-pm

## Dependencies (3)

- [which-pm](https://npm.io/package/which-pm.md) ^4.0.0
- [find-up-simple](https://npm.io/package/find-up-simple.md) ^1.0.1
- [find-yarn-workspace-root2](https://npm.io/package/find-yarn-workspace-root2.md) 1.2.53

## Recent versions

- 5.0.0 (latest) — 2026-03-11
- 3.0.2 (pnpm-temp) — 2020-08-14
- 4.1.1 — 2025-02-03
- 4.1.0 — 2025-01-29
- 4.0.0 — 2024-07-06
- 3.1.4 — 2024-07-04
- 3.1.3 — 2024-02-22
- 3.1.2 — 2023-09-05
- 3.1.1 — 2023-08-31
- 3.1.0 — 2023-08-31
- 3.0.3 — 2021-02-09
- 3.0.1 — 2020-06-29
- 3.0.0 — 2020-04-17
- 2.0.0 — 2019-05-24
- 1.0.1 — 2018-03-08
- … 1 more at https://npm.io/package/preferred-pm/versions

## README

# preferred-pm

> Returns the preferred package manager of a project

[![npm version](https://img.shields.io/npm/v/preferred-pm.svg)](https://www.npmjs.com/package/preferred-pm)

* Inside a Yarn workspace, Yarn is preferred.
* Inside a pnpm workspace, pnpm is preferred.
* If a `package-lock.json` is present, npm is preferred.
* If a `yarn.lock` is present, Yarn is preferred.
* If a `pnpm-lock.yaml` is present, pnpm is preferred.
* If a `bun.lockb` is present, Bun is preferred.
* If a `node_modules` is present, tries to detect which package manager installed it.

## Installation

```
<pnpm|yarn|npm|bun> add preferred-pm
```

## Usage

```js
'use strict'
const preferredPM = require('preferred-pm')

preferredPM(process.cwd())
    .then(pm => console.log(pm))
//> {name: "npm", version: ">=5"}
```

## Related

* [which-pm](https://github.com/zkochan/packages/tree/main/which-pm) - Detects what package manager was used for installation
* [which-pm-runs](https://github.com/zkochan/packages/tree/main/which-pm-runs) - Detects what package manager executes the process

## License

[MIT](LICENSE) © [Zoltan Kochan](https://kochan.io)

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