Represents a specific version of an npm package, providing access to its manifest.

Implements PromiseLike<NpmPackageVersion> so it can be awaited directly.

// Await directly to get the version manifest
const manifest = await npm.package('react').version('18.2.0');

// Or call .get() explicitly
const manifest = await npm.package('react').version('18.2.0').get();

Implements

Methods

  • Fetches CDN usage statistics for this specific version from jsDelivr.

    At version level, results are grouped by file by default, showing which individual files are most requested from browsers in production.

    GET /package/npm/{name}@{version}/stats/{groupBy}/{period} (via data.jsdelivr.com/v1)

    Parameters

    • groupBy: JsdelivrGroupBy = 'file'

      Group results by 'file' (default) or 'date'

    • period: JsdelivrPeriod = 'month'

      Time period: 'day', 'week', 'month' (default), or 'year'

    • Optionalsignal: AbortSignal

      Optional AbortSignal to cancel the request

    Returns Promise<JsdelivrStats>

    CDN hit counts and bandwidth breakdown by file or date

    const stats = await npm.package('react').version('18.2.0').cdnStats();
    console.log(stats.total);
  • Fetches the fully resolved dependency graph for this version from deps.dev.

    Unlike the semver ranges in package.json, this returns exact resolved versions for every direct and transitive dependency, along with the dependency graph edges.

    GET /systems/npm/packages/{name}/versions/{version}:dependencies (via api.deps.dev/v3)

    Parameters

    • Optionalsignal: AbortSignal

      Optional AbortSignal to cancel the request

    Returns Promise<DepsDevDependencies>

    Dependency nodes (with resolved versions and relation type) and graph edges

    const deps = await npm.package('react').version('18.2.0').dependencies();
    const direct = deps.nodes.filter(n => n.relation === 'DIRECT');
    console.log(direct.map(n => `${n.versionKey.name}@${n.versionKey.version}`));
  • Fetches the download count for this specific version over the previous 7 days.

    npm exposes version-level download counts only for last-week.

    GET /versions/{package}/last-week (via api.npmjs.org)

    Parameters

    • period: "last-week" = 'last-week'

      Must be 'last-week'

    • Optionalsignal: AbortSignal

      Optional AbortSignal to cancel the request

    Returns Promise<NpmVersionDownloadPoint>

    Download point data for this version

    const stats = await npm.package('react').version('18.2.0').downloads('last-week');
    console.log(stats.downloads);
  • Fetches the complete file tree of this package version from unpkg.

    Returns every file and directory included in the published tarball, with individual file sizes, types, and paths — useful for auditing package contents.

    GET /{name}@{version}/?meta (via unpkg.com)

    Parameters

    • Optionalsignal: AbortSignal

      Optional AbortSignal to cancel the request

    Returns Promise<UnpkgFile>

    Recursive file tree of the package

    const tree = await npm.package('react').version('18.2.0').files();
    tree.files?.forEach(f => console.log(f.path, f.size));
  • Fetches the publish size and full install size (including all transitive dependencies) for this specific version from Packagephobia.

    GET /v2/api.json?p={name}@{version} (via packagephobia.com)

    Parameters

    • Optionalsignal: AbortSignal

      Optional AbortSignal to cancel the request

    Returns Promise<PackagephobiaSize>

    Publish and install size in bytes, file counts, and human-readable strings

    const size = await npm.package('react').version('18.2.0').size();
    console.log(size.install.pretty); // "300 kB"