Skip to content

antfu-collective/local-pkg

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

About

Get information on local packages.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Sponsor this project

 

Packages

 
 
 

Contributors