publish

npm pack

Creates the tarball (`<name>-<version>.tgz`) exactly as `npm publish` would upload, without actually publishing. Perfect for previewing shipped files or for installing locally to test.

npm pack [<pkg>|<folder>] [--dry-run]

Common flags

Flag Purpose
--dry-run List the files that would be packed without writing the tarball
--json Emit the file list and metadata as JSON
--pack-destination <dir> Write the .tgz to a specific directory

Examples

npm pack --dry-run

Preview the exact file list that publish would send

npm pack

Produce my-pkg-1.0.0.tgz in the current directory

npm install ./my-pkg-1.0.0.tgz

Install the packed tarball locally to test it

Gotcha

The tarball respects the `files` field and .npmignore — always run `npm pack --dry-run` before publishing to catch accidentally-included secrets or oversized files. If `files` is missing, .gitignore is used as a fallback ignore.

Related commands

← All npm commands · npm vs pnpm vs Yarn · Fix Node OOM