# has-yarn

> Check if a project is using Yarn

Latest version **4.0.0** (published 2025-09-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install has-yarn
pnpm add has-yarn
yarn add has-yarn
bun add has-yarn
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

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

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2025-09-14 |
| First published | 2016-12-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=20 |
| Dependencies | 1 |
| Unpacked size | 3.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 98 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | yarn, has, detect, is, project, app, module, package, manager, npm |

## Links

- npm: https://www.npmjs.com/package/has-yarn
- Repository: https://github.com/sindresorhus/has-yarn
- Homepage: https://github.com/sindresorhus/has-yarn#readme
- Issues: https://github.com/sindresorhus/has-yarn/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/has-yarn

## Dependencies (1)

- [find-up-simple](https://npm.io/package/find-up-simple.md) ^1.0.1

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 4.0.0 (latest) — 2025-09-14
- 3.0.0 — 2021-09-10
- 2.1.0 — 2019-03-31
- 2.0.0 — 2019-03-12
- 1.0.0 — 2016-12-12

## README

# has-yarn

> Check if a project is using [Yarn](https://yarnpkg.com)

Useful for tools that needs to know whether to use `yarn` or `npm` to install dependencies.

It checks for a `yarn.lock` file in the given directory or any of its parent directories (useful for Yarn workspaces).

## Install

```sh
npm install has-yarn
```

## Usage

```
.
├── foo
│   └── package.json
└── bar
    ├── package.json
    └── yarn.lock
```

```js
import hasYarn from 'has-yarn';

hasYarn('foo');
//=> false

hasYarn('bar');
//=> true

// In a Yarn workspace
hasYarn('bar/packages/some-package');
//=> true
```

## API

### hasYarn(cwd?)

Returns a `boolean` of whether the project uses Yarn.

#### cwd

Type: `string`\
Default: `process.cwd()`

The directory to check. The search also walks up parent directories until the filesystem root.

## Related

- [has-yarn-cli](https://github.com/sindresorhus/has-yarn-cli) - CLI for this package

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