# find-and-require-package-json

> Find the package.json file from within a build/package

Latest version **0.9.1** (published 2026-01-29) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 65/100 (B)** — status: stable.

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

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.9.1 |
| Published | 2026-01-29 |
| First published | 2025-12-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Constructive <developers@constructive.io> |
| Maintainers | pyramation |

## Links

- npm: https://www.npmjs.com/package/find-and-require-package-json
- Repository: https://github.com/constructive-io/dev-utils
- Issues: https://github.com/constructive-io/dev-utils/issues
- npm.io page: https://npm.io/package/find-and-require-package-json

## Recent versions

- 0.9.1 (latest) — 2026-01-29
- 0.9.0 — 2026-01-20
- 0.8.6 — 2026-01-07
- 0.8.5 — 2025-12-27
- 0.8.4 — 2025-12-27
- 0.8.3 — 2025-12-27
- 0.8.2 — 2025-12-17
- 0.8.1 — 2025-12-14
- 0.8.0 — 2025-12-13
- 0.6.8 — 2025-12-13

## README

# find-and-require-package-json

<p align="center">
  <img src="https://raw.githubusercontent.com/constructive-io/constructive/refs/heads/main/assets/outline-logo.svg" height="250">
  <br />
    Find the package.json file from within a build/package
  <br />
  <a href="https://github.com/constructive-io/dev-utils/actions/workflows/ci.yml">
    <img height="20" src="https://github.com/constructive-io/dev-utils/actions/workflows/ci.yml/badge.svg" />
  </a>
  <a href="https://github.com/constructive-io/dev-utils/blob/main/LICENSE">
    <img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/>
  </a>
</p>

This TypeScript module provides a function to locate, read, and parse the `package.json` file starting from a specified directory and searching up through parent directories.

## install

```sh
npm install find-and-require-package-json
```

### Example

```js
import { findAndRequirePackageJson } from 'find-and-require-package-json';

// Pass __dirname to find the package.json for your module
const packageJson = findAndRequirePackageJson(__dirname);
console.log('Package name:', packageJson.name);
console.log('Version:', packageJson.version);
```

### ESM Usage

For ESM modules, you'll need to convert `import.meta.url` to a directory path:

```js
import { findAndRequirePackageJson } from 'find-and-require-package-json';
import { dirname } from 'path';
import { fileURLToPath } from 'url';

const __dirname = dirname(fileURLToPath(import.meta.url));
const packageJson = findAndRequirePackageJson(__dirname);
```

---

## Development

### Setup

1. Clone the repository:

```bash
git clone https://github.com/constructive-io/dev-utils.git
```

2. Install dependencies:

```bash
cd dev-utils
pnpm install
pnpm build
```

3. Test the package of interest:

```bash
cd packages/<packagename>
pnpm test:watch
```

## Credits

**🛠 Built by the [Constructive](https://constructive.io) team — creators of modular Postgres tooling for secure, composable backends. If you like our work, contribute on [GitHub](https://github.com/constructive-io).**

## Disclaimer

AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.

No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.

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