When preparing a package release, you may want to preview the upcoming release locally. The NPM CLI has a handy command to create a tarball locally:
NPM Quick Tips Series Overview
- Create a Local Release Package Before Publishing to the Registry
- How to Run ESLint --fix From npm Script
Create a Local Release Package
Running the npm pack
command in a directory containing a package.json
file will create a .tar.gz
archive:
npm pack
The NPM CLI follows the package configuration and loads the package into the local cache. It copies the resulting tarball to the current directory.
When Is This Helpful?
We recently configured the files
attribute in package.json
to publish a reduced set of files in the repository. A release tarball should be as small as possible. To reduce the file size of a release, we only include the required source file for the package and removed tests, images, and ESLint configurations.
Enjoy local packaging!
Mentioned Resources
- Docs for
npm pack
- Docs for the
files
attribute in package.json