pkg-infoh
v0.0.2
Published
📦 Retrieve details of local packages
Downloads
5
Readme
ℹ️ pkg-infoh
📦 Retrieve details of local packages. Works on both CJS and ESM.
⬇️ Install:
# nyxi
nyxi pkg-infoh
# pnpm
pnpm add pkg-infoh
# npm
npm i pkg-infoh
# yarn
yarn add pkg-infoh
Usage
import {
getPackageInfo,
importModule,
isPackageExists,
resolveModule,
} from 'pkg-infoh'
isPackageExists('pkg-infoh') // true
isPackageExists('foo') // false
await getPackageInfo('pkg-infoh')
/* {
* name: "local-pkg",
* version: "0.1.0",
* rootPath: "/path/to/node_modules/pkg-infoh",
* packageJson: {
* ...
* }
* }
*/
// similar to `require.resolve` but works also in ESM
resolveModule('pkg-infoh')
// '/path/to/node_modules/local-pkg/dist/index.cjs'
// similar to `await import()` but works also in CJS
const { importModule } = await importModule('pkg-infoh')
📜 License
MIT - Made with 💞