# read-pkg-up

> Read the closest package.json file

Latest version **11.0.0** (published 2023-11-03) · 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/read-pkg-up)

## Install

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

## Health

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

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 11.0.0 |
| Published | 2023-11-03 |
| First published | 2015-09-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=18 |
| Dependencies | 3 |
| Unpacked size | 6.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 267 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | json, read, parse, file, fs, graceful, load, package, 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/read-pkg-up
- Repository: https://github.com/sindresorhus/read-pkg-up
- Homepage: https://github.com/sindresorhus/read-pkg-up#readme
- Issues: https://github.com/sindresorhus/read-pkg-up/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/read-pkg-up

## Dependencies (3)

- [read-pkg](https://npm.io/package/read-pkg.md) ^9.0.0
- [type-fest](https://npm.io/package/type-fest.md) ^4.6.0
- [find-up-simple](https://npm.io/package/find-up-simple.md) ^1.0.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 11.0.0 (latest) — 2023-11-03
- 10.1.0 — 2023-08-22
- 10.0.0 — 2023-07-04
- 9.1.0 — 2022-02-08
- 9.0.0 — 2021-10-13
- 8.0.0 — 2021-03-28
- 7.0.1 — 2019-12-06
- 7.0.0 — 2019-09-27
- 6.0.0 — 2019-05-12
- 5.0.0 — 2019-03-21
- 4.0.0 — 2018-06-18
- 3.0.0 — 2017-11-04
- 2.0.0 — 2016-10-11
- 1.0.1 — 2015-09-03

## README

# read-pkg-up

> Read the closest package.json file

## Why

- [Finds the closest package.json](https://github.com/sindresorhus/find-up)
- [Throws more helpful JSON errors](https://github.com/sindresorhus/parse-json)
- [Normalizes the data](https://github.com/npm/normalize-package-data#what-normalization-currently-entails)

## Install

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

## Usage

```js
import {readPackageUp} from 'read-pkg-up';

console.log(await readPackageUp());
/*
{
	packageJson: {
		name: 'awesome-package',
		version: '1.0.0',
		…
	},
	path: '/Users/sindresorhus/dev/awesome-package/package.json'
}
*/
```

## API

### readPackageUp(options?)

Returns a `Promise<object>`, or `Promise<undefined>` if no `package.json` was found.

### readPackageUpSync(options?)

Returns the result object, or `undefined` if no `package.json` was found.

#### options

Type: `object`

##### cwd

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

The directory to start looking for a package.json file.

##### normalize

Type: `boolean`\
Default: `true`

[Normalize](https://github.com/npm/normalize-package-data#what-normalization-currently-entails) the package data.

## Related

- [read-pkg](https://github.com/sindresorhus/read-pkg) - Read a package.json file
- [pkg-up](https://github.com/sindresorhus/pkg-up) - Find the closest package.json file
- [find-up](https://github.com/sindresorhus/find-up) - Find a file by walking up parent directories
- [pkg-conf](https://github.com/sindresorhus/pkg-conf) - Get namespaced config from the closest package.json

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