# archiver

> a streaming interface for archive generation

Latest version **8.0.0** (published 2026-05-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install archiver
pnpm add archiver
yarn add archiver
bun add archiver
```

## Health

**Score 68/100 (B)** — status: active.

Positive: has types package; esm support; no vulnerabilities; has provenance; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 8.0.0 |
| Published | 2026-05-08 |
| First published | 2012-10-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/archiver) |
| Module format | ESM |
| Node | >=18 |
| Dependencies | 9 |
| Unpacked size | 38.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 2977 |
| Author | Chris Talkington |
| Maintainers | ctalkington |
| Keywords | archive, archiver, stream, zip, tar |

## Links

- npm: https://www.npmjs.com/package/archiver
- Repository: https://github.com/archiverjs/node-archiver
- Issues: https://github.com/archiverjs/node-archiver/issues
- npm.io page: https://npm.io/package/archiver

## Dependencies (9)

- [async](https://npm.io/package/async.md) ^3.2.4
- [is-stream](https://npm.io/package/is-stream.md) ^4.0.0
- [lazystream](https://npm.io/package/lazystream.md) ^1.0.0
- [tar-stream](https://npm.io/package/tar-stream.md) ^3.0.0
- [zip-stream](https://npm.io/package/zip-stream.md) ^7.0.2
- [buffer-crc32](https://npm.io/package/buffer-crc32.md) ^1.0.0
- [readdir-glob](https://npm.io/package/readdir-glob.md) ^3.0.0
- [normalize-path](https://npm.io/package/normalize-path.md) ^3.0.0
- [readable-stream](https://npm.io/package/readable-stream.md) ^4.0.0

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 8.0.0 (latest) — 2026-05-08
- 0.15.0-1 (canary) — 2015-06-05
- 7.0.1 — 2024-03-10
- 7.0.0 — 2024-02-28
- 6.0.2 — 2024-02-27
- 6.0.1 — 2023-09-04
- 6.0.0 — 2023-08-18
- 5.3.2 — 2023-08-17
- 5.3.1 — 2022-04-15
- 5.3.0 — 2021-03-07
- 5.2.0 — 2021-01-07
- 5.1.0 — 2020-11-20
- 5.0.2 — 2020-09-11
- 5.0.1 — 2020-09-11
- 5.0.0 — 2020-07-23
- … 69 more at https://npm.io/package/archiver/versions

## README

# Archiver

A streaming interface for archive generation

Visit the [API documentation](https://www.archiverjs.com/) for a list of all methods available.

## Install

```bash
npm install archiver --save
```

## Quick Start

```js
import fs from "fs";
import { ZipArchive } from "archiver";

// create a file to stream archive data to.
const output = fs.createWriteStream(__dirname + "/example.zip");
const archive = new ZipArchive({
  zlib: { level: 9 }, // Sets the compression level.
});

// listen for all archive data to be written
// 'close' event is fired only when a file descriptor is involved
output.on("close", function () {
  console.log(archive.pointer() + " total bytes");
  console.log(
    "archiver has been finalized and the output file descriptor has closed.",
  );
});

// This event is fired when the data source is drained no matter what was the data source.
// It is not part of this library but rather from the NodeJS Stream API.
// @see: https://nodejs.org/api/stream.html#stream_event_end
output.on("end", function () {
  console.log("Data has been drained");
});

// good practice to catch warnings (ie stat failures and other non-blocking errors)
archive.on("warning", function (err) {
  if (err.code === "ENOENT") {
    // log warning
  } else {
    // throw error
    throw err;
  }
});

// good practice to catch this error explicitly
archive.on("error", function (err) {
  throw err;
});

// pipe archive data to the file
archive.pipe(output);

// append a file from stream
const file1 = __dirname + "/file1.txt";
archive.append(fs.createReadStream(file1), { name: "file1.txt" });

// append a file from string
archive.append("string cheese!", { name: "file2.txt" });

// append a file from buffer
const buffer3 = Buffer.from("buff it!");
archive.append(buffer3, { name: "file3.txt" });

// append a file
archive.file("file1.txt", { name: "file4.txt" });

// append files from a sub-directory and naming it `new-subdir` within the archive
archive.directory("subdir/", "new-subdir");

// append files from a sub-directory, putting its contents at the root of archive
archive.directory("subdir/", false);

// append files from a glob pattern
archive.glob("file*.txt", { cwd: __dirname });

// finalize the archive (ie we are done appending files but streams have to finish yet)
// 'close', 'end' or 'finish' may be fired right after calling this method so register to them beforehand
archive.finalize();
```

## Formats

Archiver ships with out of the box support for TAR and ZIP archives.

---
_Source: https://npm.io/package/archiver · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
