npm pack: Build a Tarball to Inspect
npm pack produces the publishable tarball without uploading.
Use npm pack to catch files that should not ship (or are missing) before a real publish.
Common usage
npm pack- write the .tgznpm pack --dry-run- list contents only--json- structured file list
Example in CI
List exactly what would publish.
shell
npm pack --dry-runIn CI
Pair with the files field and .npmignore to control package contents. Run this as a release guard before npm publish.
Key takeaways
npm pack --dry-runpreviews package contents.- Catch missing or stray files pre-release.
- Control contents with
files/.npmignore.