'Is there a way to list what `npm publish` will actually publish?

The docs explain how to control which files are not sent to the npm registry when you run npm publish.

If you use .npmignore, or you're not using git that set of files differs from the set that are pushed to your source repo.

Is there a way to list the files that npm publish will send?

I know that npm pack will create a tarball that contains those files, but creating a tarball and then listing its contents seems a little clunky.

npm


Solution 1:[1]

Currently, there's no such thing in npm (see this issue).

At the moment you can use some external tools that implement the functionality you're asking for, e.g. pkgfiles or irish-pub.

Solution 2:[2]

As of at least npm@6, you can run npm publish --dry-run to see what files are included in your package.

https://docs.npmjs.com/cli/v6/commands/npm-publish

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 eush77
Solution 2 neverendingqs