You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Marek Piasecki
06fbe82dce
|
2 years ago | |
---|---|---|
.. | ||
dist | 2 years ago | |
LICENSE | 2 years ago | |
README.md | 2 years ago | |
index.cjs | 2 years ago | |
index.d.ts | 2 years ago | |
index.mjs | 2 years ago | |
package.json | 2 years ago |
README.md
local-pkg
Get information on local packages. Works on both CJS and ESM.
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 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
License
MIT License © 2021 Anthony Fu