archiver
Streaming interface for generating ZIP and TAR archives in Node.js — create compressed archives programmatically from files, directories, and buffers.
archiver
General JSStreaming interface for generating ZIP and TAR archives in Node.js — create compressed archives programmatically from files, directories, and buffers.
Fit
Bundle (gzip)
66.8 kB
225.4 kB raw
Install size includes transitive dependencies. Bundle size is gzipped browser payload.
Freshness
The Problem
Creating ZIP or TAR archives in Node.js — for export features, backup utilities, or distributing generated files — requires streaming multiple sources into a compressed output without loading everything into memory.
What It Does
Archiver creates a writable stream that accepts files, directories, and raw buffers. It compresses them into ZIP (with deflate) or TAR (with gzip) format and pipes the result to a file stream or HTTP response. Directory archiving handles recursive file trees automatically.
Installation
npm install archiver
npm install -D @types/archiverUsage Example
import archiver from 'archiver';
import { createWriteStream } from 'fs';
const output = createWriteStream('project-export.zip');
const archive = archiver('zip', { zlib: { level: 9 } });
output.on('close', () => console.log(`Archive created: ${archive.pointer()} bytes`));
archive.on('error', (err) => { throw err; });
archive.pipe(output);
// Add individual files
archive.file('README.md', { name: 'README.md' });
// Add entire directory
archive.directory('src/', 'src');
// Add buffer as file
archive.append(Buffer.from('{"version": 1}'), { name: 'metadata.json' });
await archive.finalize();Related packages
Unified TypeScript SDK for building AI-powered apps — switch between 20+ LLM providers without rewriting code.
animejsGeneral JSLightweight JavaScript animation library with a tiny footprint and a powerful, expressive API.
AOSGeneral JSAn easy-to-use library that makes elements fade, slide, or zoom into view as the user scrolls down your page.
@formkit/auto-animateGeneral JS> Add smooth transitions to any element with a single line — zero-config animations for adds, removes, and moves.
axiosGeneral JSPromise-based HTTP client for the browser and Node.js — interceptors, automatic JSON parsing, request cancellation, and progress events.