node-zip is a Node.js library for zipping and unzipping files, originally ported from an older version of JSZip. The current and only stable version is 1.1.1, which was last published over a decade ago in May 2015. This package is explicitly identified as a legacy and unmaintained project by the wider Node.js community, with strong recommendations against its use in new development due to potential security vulnerabilities, lack of modern features, and inherent performance limitations for large files. Modern alternatives like `jszip`, `adm-zip`, or `zip-stream` are recommended for active projects, offering better maintenance, asynchronous APIs, and streaming capabilities.
npm install node-zipVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a ZIP archive with text and binary content, save it to disk, and then read/extract files from the created ZIP using `node-zip`.
Migrate to actively maintained alternatives such as `jszip` (for browser and Node.js), `adm-zip` (Node.js, synchronous), or `zip-stream`/`archiver` (Node.js, streaming for large files).
Ensure `fs.writeFileSync('file.zip', data, 'binary');` is used. Do not rely on default string encodings.Always use `const Zip = require('node-zip');` to import the library. If your project is ESM-only, you may need a wrapper or to transition to a modern, ESM-compatible zip library.For large files, use streaming-based libraries (e.g., `zip-stream`, `unzipper`) which process data in chunks to conserve memory and avoid blocking. If you must use `node-zip`, process smaller files only.
Immediately migrate to a well-maintained and actively supported zip library that has a track record of addressing security concerns.
If your project is ES Module-based, you must use `import { createRequire } from 'module'; const require = createRequire(import.meta.url); const Zip = require('node-zip');`. However, migrating to a modern, ESM-compatible zip library is highly recommended.The primary export of `node-zip` is a constructor function. It must be instantiated with `new`: `const Zip = require('node-zip'); const zipInstance = new Zip();`.Ensure that when writing the ZIP buffer to a file, `fs.writeFileSync` uses the `'binary'` encoding: `fs.writeFileSync('output.zip', data, 'binary');`. Also verify the integrity of the input ZIP file.Consider `node-zip` unsuitable for large files. Migrate to streaming-based zip libraries (e.g., `unzipper`, `zip-stream`) for efficient memory management when handling large archives.
No dependency data recorded yet.