LinuxCommandLibrary

npm-pack

creates a tarball of a package exactly as it would be published

TLDR

Pack current package

$ npm pack
copy
Pack specific package
$ npm pack [package]
copy
Pack without gzip
$ npm pack --pack-destination [./dist]
copy
Dry run (list contents)
$ npm pack --dry-run
copy
Output as JSON
$ npm pack --json
copy

SYNOPSIS

npm pack [options] [packages...]

DESCRIPTION

npm pack creates a tarball of a package exactly as it would be published. This is useful for testing what will be included in a published package.
The tarball can be installed locally to test the package.

PARAMETERS

--dry-run

Show contents without packing.
--json
Output as JSON.
--pack-destination dir
Output directory.
--workspace ws
Pack specific workspace.

WORKFLOW

$ # Create tarball
npm pack
# Creates package-1.0.0.tgz

# Test installation
npm install ./package-1.0.0.tgz

# Check contents without creating file
npm pack --dry-run
copy

FILES INCLUDED

$ - Files in package.json "files"
- package.json
- README
- LICENSE
- CHANGELOG
Excluded by .npmignore
copy

CAVEATS

Different from npm publish. Respects .npmignore and files field. Useful for pre-publish testing.

HISTORY

npm pack was added to allow developers to test package contents before publishing to the registry.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community