# new-find-package-json

> Find the an package.json in the path provided upwards

Latest version **2.0.0** (published 2022-05-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install new-find-package-json
pnpm add new-find-package-json
yarn add new-find-package-json
bun add new-find-package-json
```

## Health

**Score 25/100 (F)** — status: abandoned.

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2022-05-24 |
| First published | 2021-07-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=12.22.0 |
| Dependencies | 1 |
| Unpacked size | 13.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | hasezoey |
| Maintainers | hasezoey |
| Keywords | package.json, json, find-package-json, directory, package-json, read-package-json |

## Links

- npm: https://www.npmjs.com/package/new-find-package-json
- Repository: https://github.com/hasezoey/new-find-package-json
- Homepage: https://github.com/hasezoey/new-find-package-json#readme
- Issues: https://github.com/hasezoey/new-find-package-json/issues
- npm.io page: https://npm.io/package/new-find-package-json

## Dependencies (1)

- [debug](https://npm.io/package/debug.md) ^4.3.4

## 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

- 2.0.0 (latest) — 2022-05-24
- 1.2.0 — 2022-05-24
- 1.1.0 — 2021-07-05
- 1.0.0 — 2021-07-05

## README

# new-find-package-json

Inspired by [`find-package-json`](https://github.com/3rd-Eden/find-package-json)

This package can find (by default) the nearest `package.json` (upwards).

## Usage

Sync:

```ts
const findFileFrom = process.cwd();
for (const file of findSync(findFileFrom)) {
  console.log("found file:", file);
}
```

Async/await (Promises):

```ts
const findFileFrom = process.cwd();
for await (const file of findAsync(findFileFrom)) {
  console.log("found file:", file);
}
```

Note: it is important to not forget to use `for await..of` instead of just `for..of` for `findAsync`

### Options

Options for `findSync` & `findAsync`:

| Index | Name | Type | Default | Description |
| :---: | :---: | :---: | :---: | :---: |
| 0 | `input` | `string` | none (required) | The path to search from |
| 1 | `base` | `string` | `process.cwd()` | The path to use as an absolute point if `input` is not absolute |
| 2 | `fileName` | `string` | `package.json` | The Filename to search for |

`.next` will return an object with `value` and `done`, where value is the absolute path to the file found and `undefined` if `done` is `true`

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