📂
File System5M+/wkMIT

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
npm install archiver
yarn
yarn add archiver
pnpm
pnpm add archiver

Import

ESM
import archiver from 'archiver';

Quick Example

usage
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

Packagearchiver
CategoryFile System
Weekly Downloads5M+
LicenseMIT
Installnpm install archiver

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.