0.0.6 • Published 11 months ago
locale-pkg v0.0.6
locale-pkg
Get information on local packages. Works on both CJS and ESM.
Install
npm i locale-pkg
Usage
import {
getPackageInfo,
importModule,
isPackageExists,
resolveModule,
} from 'locale-pkg'
isPackageExists('locale-pkg') // true
isPackageExists('foo') // false
await getPackageInfo('locale-pkg')
/* {
* name: "locale-pkg",
* version: "0.1.0",
* rootPath: "/path/to/node_modules/locale-pkg",
* packageJson: {
* ...
* }
* }
*/
// similar to `require.resolve` but works also in ESM
resolveModule('locale-pkg')
// '/path/to/node_modules/local-pkg/dist/index.cjs'
// similar to `await import()` but works also in CJS
const { importModule } = await importModule('locale-pkg')