adm-zip: nodejs 中 zip文件压缩神器

2025年08月28日 13:49:24
6169
nodejs 文件操作 压缩解压
adm-zip cthackers/adm-zip

ADM - ZIP是用于NodeJS的纯JavaScript实现的ZIP数据压缩库。可通过npm安装,无其他NodeJS依赖。能解压、压缩文件,更新ZIP内容。更多详情查看wiki。

项目大小 1.1 KB
涉及语言 JavaScript 100.00%
许可协议 LICENSE
仓库同步说明
  • • 同步需要仓库写入权限以创建目标仓库
  • • 使用平台账号授权登录后将同步到您平台下的个人仓库

ADM-ZIP for NodeJS

ADM-ZIP is a pure JavaScript implementation for zip data compression for NodeJS.

Build Status

Installation

With npm do:

$ npm install adm-zip
      

Electron file system support described below.

What is it good for?

The library allows you to:

  • decompress zip files directly to disk or in memory buffers
  • compress files and store them to disk in .zip format or in compressed buffers
  • update content of/add new/delete files from an existing .zip

Dependencies

There are no other nodeJS libraries that ADM-ZIP is dependent of

Examples

Basic usage

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
var AdmZip = require("adm-zip");
 
// reading archives
var zip = new AdmZip("./my_file.zip");
var password = "1234567890";
var zipEntries = zip.getEntries(); // an array of ZipEntry records - add password parameter if entries are password protected
 
zipEntries.forEach(function (zipEntry) {
    console.log(zipEntry.toString()); // outputs zip entries information
    if (zipEntry.entryName == "my_file.txt") {
        console.log(zipEntry.getData().toString("utf8"));
    }
});
// outputs the content of some_folder/my_file.txt
console.log(zip.readAsText("some_folder/my_file.txt"));
// extracts the specified file to the specified location
zip.extractEntryTo(/*entry name*/ "some_folder/my_file.txt", /*target path*/ "/home/me/tempfolder", /*maintainEntryPath*/ false, /*overwrite*/ true);
// extracts everything
zip.extractAllTo(/*target path*/ "/home/me/zipcontent/", /*overwrite*/ true);
 
// creating archives
var zip = new AdmZip();
 
// add file directly
var content = "inner content of the file";
zip.addFile("test.txt", Buffer.from(content, "utf8"), "entry comment goes here");
// add local file
zip.addLocalFile("/home/me/some_picture.png");
// get everything as a buffer
var willSendthis = zip.toBuffer();
// or write everything to disk
zip.writeZip(/*target file name*/ "/home/me/files.zip");
 
// ... more examples in the wiki

For more detailed information please check out the wiki.

Electron original-fs

ADM-ZIP has supported electron original-fs for years without any user interractions but it causes problem with bundlers like rollup etc. For continuing support original-fs or any other custom file system module. There is possible specify your module by fs option in ADM-ZIP constructor.

Example:

1
2
3
4
5
6
7
8
const AdmZip = require("adm-zip");
const OriginalFs = require("original-fs");
 
// reading archives
const zip = new AdmZip("./my_file.zip", { fs: OriginalFs });
.
.
.

                

                

免责声明 © 2026 - 虚宝阁

本站部分源码来源于网络,版权归属原开发者,用户仅获得使用权。依据《计算机软件保护条例》第十六条,禁止:

  • 逆向工程破解技术保护措施
  • 未经许可的分发行为
  • 去除源码中的原始版权标识

※ 本站源码仅用于学习和研究,禁止用于商业用途。如有侵权, 请及时联系我们进行处理。

侵权举报请提供: 侵权页面URL | 权属证明模板

响应时效:收到完整材料后48小时内处理

相关推荐

image-compressor: 前端图片压缩库

image-compressor: 前端图片压缩库

超轻量的前端图片压缩库,就像一个智能“图片瘦身教练”,能在浏览器里直接把大图片压缩到合适大小,而且不影响视觉效果。 • 压缩后仅20KB,比一张表情包还小 • 支持JPEG、PNG、WebP等主流格式 • 零依赖,原生JavaScript编写 • 每周下载量稳定在10万+

5660 2025-10-20
simple-git Node.js 中简单易用的Git操作神器

simple-git Node.js 中简单易用的Git操作神器

Simple-Git 是一个基于 Node.js 的库,它为开发者提供了一种简单而直观的方式来执行 Git 命令。通过使用 Simple-Git,你可以在 Node.js 应用程序中轻松地执行诸如提交、推送、拉取等操作,而无需手动执行 Git 命令行。

3734 2025-09-13
Seelen-UI: 高度可定制的 Windows 桌面美化工具

Seelen-UI: 高度可定制的 Windows 桌面美化工具

一款免费开源的 Windows 桌面增强工具,专注于高度自定义和效率提升。它采用 Rust 语言开发,结合 Tauri 框架与 Web 技术,支持窗口平铺管理、应用启动器、Dock、任务栏、动态壁纸、插件扩展等功能。

13691 2025-10-04
n8n: AI自动化工作流工具

n8n: AI自动化工作流工具

基于节点的自动化工作流工具,能帮助用户轻松创建和管理复杂的自动化流程,无需编写大量代码。并且内置了AI能力,支持 400+ 应用和服务!

146989 2025-09-26
markdown-it

markdown-it

markdown-it是一款快速且易扩展的Markdown解析器,遵循CommonMark规范并添加语法扩展。它配置灵活、速度快且安全,还有丰富的社区插件。

20415 2025-09-09
node-qrcode

node-qrcode

qr code generator

7955 2025-10-17
TensorFlow.js: javascript界的机器学习大神

TensorFlow.js: javascript界的机器学习大神

TensorFlow.js 把机器学习能力带进了 JavaScript。训练模型、运行推理,甚至搞实时 AI Web 或移动端、Node 后端。谷歌用,创业公司用,爱好者用,用过都说好。

18976 2025-10-01
ant-design-vue-pro

ant-design-vue-pro

👨🏻‍💻👩🏻‍💻 Use Ant Design Vue like a Pro! (vue2)

10932 2025-09-20
fastapi: Python web api 框架

fastapi: Python web api 框架

一个基于 Python 3.6+ 版本的异步 WEB 应用框架,使用 Python 类型注解构建 web API 。主要特点有: 高性能:与 Node JS 和 Go 相当。 编码快:将开发功能的速度提高 2~3 倍。 Bug少:减少大约 40% 的由开发人员导致的错误。 直观:强大的编辑器支持,可智能感知和补全代码。 简单:易于学习和使用,减少文档阅读时间。 简短:尽量减少代码重复。 健壮:获得可用于生产的代码,具有自动交互文档。 基于标准:基于 OpenAPI 和 JSON Schema 。

90539 2025-09-16

仓库下载

gitee

GitHub 下载代理

文件信息

文件名
文件大小
文件类型
代理耗时