compress-commons is a Node.js library that provides a common, low-level interface for defining and working with various archive formats, particularly ZIP, within a Node.js environment. Inspired by the established Java library Apache Commons Compress, it aims to offer foundational building blocks and structures (like file headers and entry definitions) for handling archive data. The current stable version is 7.0.0, which transitioned to being an ESM-only package and requires Node.js v18 or newer. While its release cadence is regular, it does not follow a strict schedule. This library differentiates itself by focusing on the underlying components and specifications of archive formats, rather than providing a high-level API for creating or extracting archives directly, making it suitable for developers who need granular control over archive manipulation.
npm install compress-commonsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to define a basic ZIP archive entry using `Headers` and `Entry` classes. It creates a mock file and then defines its corresponding archive header and entry object. It's a low-level definition, not a complete archiving process.
Migrate your project to ES Modules and use `import` statements, or stick to an earlier version of `compress-commons` if CommonJS is strictly required.
Upgrade your Node.js environment to version 18 or newer.
Upgrade your Node.js environment to version 14 or higher (or >=18 for v7.0.0+).
Upgrade your Node.js environment to version 12 or higher (or >=18 for v7.0.0+).
Understand that `compress-commons` provides building blocks. For full archive creation or extraction, consider using higher-level libraries that leverage `compress-commons` internally, such as `archiver`.
Change `const { Symbol } = require('compress-commons/zip');` to `import { Symbol } from 'compress-commons/zip';` and ensure your project is configured for ESM (e.g., `"type": "module"` in package.json or using `.mjs` file extensions).Ensure that the `path` property is explicitly provided as a string when creating `Headers` or `Entry` instances, e.g., `new Headers({ path: 'my-file.txt', ... })`.Always instantiate `Headers` and `Entry` using the `new` keyword: `const header = new Headers({...});`.