antfu-collective/local-pkg

Get information on local packages.

TypeScript

186

58 commits

updated May 21, 2026

See the code

README

local-pkg

NPM version

Get information on local packages.

Install

npm i local-pkg

Usage

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 in ESM
resolveModule('local-pkg')
// '/path/to/node_modules/local-pkg/dist/index.mjs'

const { importModule } = await importModule('local-pkg')

Sponsors

Sponsors

License

MIT License © 2021 Anthony Fu

Significant stargazers

Mao Mr

95 followers · starred Mar 2025

Dustin Deus

422 followers · starred Jun 2023

Garfield Lee

475 followers · starred Nov 2024

ChangeHow

29 followers · starred Dec 2024

antfu-collective/local-pkg

Get information on local packages.

TypeScript

186

58 commits

updated May 21, 2026

See the code

README

local-pkg

NPM version

Get information on local packages.

Install

npm i local-pkg

Usage

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 in ESM
resolveModule('local-pkg')
// '/path/to/node_modules/local-pkg/dist/index.mjs'

const { importModule } = await importModule('local-pkg')

Sponsors

Sponsors

License

MIT License © 2021 Anthony Fu

Significant stargazers

Mao Mr

95 followers · starred Mar 2025

Dustin Deus

422 followers · starred Jun 2023

Garfield Lee

475 followers · starred Nov 2024

ChangeHow

29 followers · starred Dec 2024