archiver
Archiver is a streaming interface for generating archive files (ZIP, TAR, TAR.GZ) in Node.js. The library creates archives by piping data through a streaming pi…
Installation
npm install archiver
yarn add archiver
pnpm add archiver
Import
import archiver from 'archiver';
Quick Example
import archiver from 'archiver';
import { createWriteStream } from 'fs';
const output = createWriteStream('archive.zip');
const archive = archiver('zip', { zlib: { level: 9 } });
archive.pipe(output);
archive.directory('src/', 'source');
archive.file('README.md', { name: 'README.md' });
await archive.finalize();About archiver
Archiver is a streaming interface for generating archive files (ZIP, TAR, TAR.GZ) in Node.js. The library creates archives by piping data through a streaming pipeline, making it memory-efficient for creating large archives without loading all files into memory simultaneously. Archiver supports adding files from the filesystem, from Buffers, from readable streams, and entire directories (with glob pattern support for filtering). The API is fluent: archive.file('path/to/file.txt', { name: 'renamed.txt' }) adds a single file, archive.directory('src/', 'source') adds an entire directory, and archive.glob('**/*.js', { cwd: 'src' }) adds files matching a pattern. Archiver provides progress events for monitoring archive creation, including entry counts and total bytes processed. The library supports ZIP-specific features like compression level, file comments, and large file support (ZIP64), and TAR-specific features like gzip compression levels and file permissions. Archiver is commonly used for creating downloadable archives in web applications, building deployment packages, creating backups, and packaging build outputs. The streaming architecture means archives can be piped directly to HTTP responses, file streams, or cloud storage upload streams without intermediate files.
Quick Facts
| Package | archiver |
| Category | File System |
| Weekly Downloads | 5M+ |
| License | MIT |
| Install | npm install archiver |
Related Packages
adm-zip is a pure JavaScript library for reading, creating, and extracting ZIP archives in Node.js w…
tar is the official npm package for reading, creating, and extracting tar archives in Node.js, suppo…
fs-extra is a drop-in replacement for Node.js's built-in fs module that adds additional file system …
rimraf is a Node.js implementation of the Unix rm -rf command, providing cross-platform recursive di…
Browse npm Packages by Category
Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.