# pkg-up

> Find the closest package.json file

Latest version **5.0.0** (published 2023-11-04) · MIT license · 0 weekly downloads

> **Deprecated.** See documentation for alternatives

> **Better alternative:** See documentation for alternatives (https://github.com/AikidoSec/module-replacements/blob/main/docs/find-up)

## Install

```sh
npm install pkg-up
pnpm add pkg-up
yarn add pkg-up
bun add pkg-up
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2023-11-04 |
| First published | 2015-09-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | ^12.20.0 \|\| ^14.13.1 \|\| >=16.0.0 |
| Dependencies | 1 |
| Unpacked size | 4.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 166 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | pkg, package, file, find, up, find-up, findup, look-up, look, search, match, resolve, parent, parents, folder, directory, walk, walking, path |

## Links

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

## Dependencies (1)

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

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 5.0.0 (latest) — 2023-11-04
- 4.0.0 — 2021-11-04
- 3.1.0 — 2019-04-15
- 3.0.1 — 2019-03-23
- 3.0.0 — 2019-03-21
- 2.0.0 — 2017-05-04
- 1.0.0 — 2015-09-21

## README

# pkg-up

> Find the closest package.json file

## Install

```sh
npm install pkg-up
```

## Usage

```
/
└── Users
    └── sindresorhus
        └── foo
            ├── package.json
            └── bar
                ├── baz
                └── example.js
```

```js
// example.js
import {pkgUp} from 'pkg-up';

console.log(await pkgUp());
//=> '/Users/sindresorhus/foo/package.json'
```

## API

### pkgUp(options?)

Returns a `Promise<string>` for the file path, or `Promise<undefined>` if it could not be found.

### pkgUpSync(options?)

Returns the file path, or `undefined` if it could not be found.

#### options

Type: `object`

#### cwd

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

The directory to start from.

## Related

- [read-pkg-up](https://github.com/sindresorhus/read-pkg-up) - Read the closest package.json file
- [pkg-dir](https://github.com/sindresorhus/pkg-dir) - Find the root directory of an npm package
- [find-up](https://github.com/sindresorhus/find-up) - Find a file by walking up parent directories

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