extract-zip is a pure JavaScript library for asynchronously extracting zip archives into a specified directory. It currently stands at version 2.0.1 and leverages the `yauzl` parser internally to handle zip file structures. Version 2.0.0 marked a significant update, introducing a modern Promise-based API that replaced the older callback-style approach, and adding official TypeScript definitions for enhanced developer experience. The library maintains an active release cadence, with recent updates (like v2.0.1) addressing critical maintenance issues such as the deprecated `process.umask` and clarifying Node.js minimum version requirements. It also offers a command-line interface for direct use. Its primary differentiators include its 100% JavaScript implementation, which avoids native binaries, and its adoption of the modern async/await pattern for all extraction operations, requiring Node.js 10.17.0 or newer.
npm install extract-zipVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `extract-zip` with its Promise-based API to extract a zip file. It sets up a temporary directory for extraction and includes basic error handling, noting that a real zip file must exist at the specified source path for actual operation.
Rewrite extraction logic to use `async/await`: `await extract(source, { dir: target })` instead of `extract(source, { dir: target }, callback)`.Upgrade your Node.js environment to version 10.12.0 or newer. For best compatibility with current versions, upgrade to >=10.17.0.
Ensure your Node.js environment is at version 10.17.0 or higher. It's recommended to use an actively maintained Node.js LTS version.
Ensure your `onEntry` callback correctly handles `(entry, zipfile)` arguments if you need access to the `yauzl` instance or raw entry data, and explicitly close the `zipfile` if you open it manually within the handler.
For CommonJS, use `const extract = require('extract-zip')`. For all versions >= 2.0.0, ensure you're using the Promise-based API with `await extract(source, options)`.Upgrade your Node.js environment to version 10.17.0 or newer. Check the official Node.js website for LTS releases.
Verify that the `source` path points to a legitimate and uncorrupted `.zip` file. Try opening the zip file manually to confirm its integrity.