Skip to content

npm: dist.fileCount counts files only, where npm pack's entryCount also counts directories, links and FIFOs #913

Open

Description

@schmitch

Summary

Found while checking npm's sizes for #600 (PR #912), which states that dist.fileCount matches npm. For a tarball of files alone, as npm pack writes them, it does. For one with other entries it differs from what the npm CLI reports:

  • crates/formats/npm/src/tarball.rs counts the entries node-tar unpacks as files (types 0, NUL, 7).
  • npm's getContents (lib/utils/tar.js) counts every entry tar.t's onentry gets (entryCount): files, and directories, links, devices and FIFOs too. Long names, PAX headers and unknown types are not counted.

Measured

npm 10.9.9 (node-tar 7.5.22), npm pack <tarball> --json --dry-run on a crafted tarball of 5 files (one under a GNU long name, one under a PAX path, one contiguous), a directory, a symlink, a hard link, a FIFO and an entry of unknown type Z: entryCount: 9. Forge's file_count for the same tarball is 5 (the regression test of #912 holds that tarball).

Not verified

Which of the two the public registry stores as dist.fileCount for such a tarball: it computes the field server-side and its source is not public. entryCount is the CLI's name for its own count, so the registry may well count files only, in which case this is to close as it stands.

Fix, if any

Decide which count dist.fileCount is meant to be; if npm's entryCount, count the entries #912 sums into unpackedSize, directories included.

Activity

  1. added this to the Backlog milestone on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions