# local-pkg

> Get information on local packages.

Latest version **1.2.1** (published 2026-05-21) · MIT license · 0 weekly downloads

## Install

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

## Health

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

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2026-05-21 |
| First published | 2021-09-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=14 |
| Dependencies | 3 |
| Unpacked size | 19.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 186 |
| Author | Anthony Fu |
| Maintainers | antfu, sxzz |
| Keywords | package |

## Links

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

## Dependencies (3)

- [mlly](https://npm.io/package/mlly.md) ^1.7.4
- [quansync](https://npm.io/package/quansync.md) ^0.2.11
- [pkg-types](https://npm.io/package/pkg-types.md) ^2.3.0

## Recent versions

- 1.2.1 (latest) — 2026-05-21
- 1.2.0 — 2026-05-19
- 1.1.2 — 2025-08-20
- 1.1.1 — 2025-03-03
- 1.1.0 — 2025-02-27
- 1.0.0 — 2025-01-09
- 0.5.1 — 2024-11-19
- 0.5.0 — 2023-10-01
- 0.4.3 — 2023-01-19
- 0.4.2 — 2022-07-12
- 0.4.1 — 2022-01-04
- 0.4.0 — 2021-10-13
- 0.3.0 — 2021-10-01
- 0.2.0 — 2021-10-01
- 0.1.0 — 2021-09-28
- … 2 more at https://npm.io/package/local-pkg/versions

## README

# local-pkg

[![NPM version](https://img.shields.io/npm/v/local-pkg?color=a1b858&label=)](https://www.npmjs.com/package/local-pkg)

Get information on local packages. Works on both CJS and ESM.

## Install

```bash
npm i local-pkg
```

## Usage

```ts
import {
  getPackageInfo,
  importModule,
  isPackageExists,
  resolveModule,
} from 'local-pkg'

isPackageExists('local-pkg') // true
isPackageExists('foo') // false

await getPackageInfo('local-pkg')
/* {
 *   name: "local-pkg",
 *   version: "0.1.0",
 *   rootPath: "/path/to/node_modules/local-pkg",
 *   packageJson: {
 *     ...
 *   }
 * }
 */

// similar to `require.resolve` but works also in ESM
resolveModule('local-pkg')
// '/path/to/node_modules/local-pkg/dist/index.cjs'

// similar to `await import()` but works also in CJS
const { importModule } = await importModule('local-pkg')
```

## Sponsors

<p align="center">
  <a href="https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg">
    <img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg'/>
  </a>
</p>

## License

[MIT](./LICENSE) License © 2021 [Anthony Fu](https://github.com/antfu)

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