# find-package

> Find the nearest package.json in your current node module

Latest version **1.0.0** (published 2015-05-25) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2015-05-25 |
| First published | 2015-05-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Javier Alba |
| Maintainers | jalba |
| Keywords | package.json, find, directory |

## Links

- npm: https://www.npmjs.com/package/find-package
- Repository: https://github.com/jalba/find-package
- Issues: https://github.com/jalba/find-package/issues
- npm.io page: https://npm.io/package/find-package

## Dependencies (1)

- [parents](https://npm.io/package/parents.md) ^1.0.1

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

- 1.0.0 (latest) — 2015-05-25

## README

# find-package
Find the nearest package.json in your current node module.

## How does it works?
The find-package module will look upstream in every paren directory until it finds a package.json file or return null.
If it finds a package.json, it wild require it and return it as an object.

## Install

```
npm install find-package

```

## Usage

If you need to access the information in the package.json of your module, simply require the find-package module and pass either `__dirname` or `process.cwd()` as the directory from where to look:

```
var findPackage = require('find-package');

console.log(findPackage(__dirname).name);
//Should return the name of the current module
//as appears in the package.json

```

## addPaths option

If you pass true as the second argument of find-package, the module will add paths object to the package.json. This object will have a `relative` and an `absolute` properties, with the correspondent relative and absolute paths to the package.json. The relative path is relative to the script calling the find-package module:

```
var package = require('find-package')(__diname, true);

package.paths.relative //string with the relative path to package.json
package.paths.absolute //string with the absolute path to package.json

```

## Disclaimer

This modules has been tested only in a UNIX environment. Although, theoretically, it should also work with Windows. If that is not the case, please let me know.

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