Nozzle Piping Mismatch

    local-pkg
    TypeScript icon, indicating that this package has built-in type declarations

    0.4.1 • Public • Published

    local-pkg

    NPM version

    Get information on local packages. Works on both CJS and ESM.

    Install

    npm i local-pkg

    Usage

    import { 
      isPackageExists,
      getPackageInfo,
      resolveModule,
      importModule,
    } 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

    Keywords

    Install

    npm i local-pkg

    DownloadsWeekly Downloads

    335,779

    Version

    0.4.1

    License

    MIT

    Unpacked Size

    27.5 kB

    Total Files

    9

    Last publish

    Collaborators

    • antfu