Registry / data / archiver-utils

archiver-utils

JSON →
library5.0.2jsnpmunverified

archiver-utils provides essential utility functions designed to support the `archiver` package, primarily focusing on file system and stream operations. As of its current stable version, 5.0.2, it offers robust capabilities for tasks such as directory traversal (`fs.walkdir`) and stream interface detection (`stream.detect`). The package maintains a relatively frequent release cadence, often aligning major version updates with Node.js EOL cycles and significant dependency upgrades. Key differentiators include its tight integration with the `archiver` ecosystem, providing specialized helpers that enhance the core archiving functionality, ensuring efficient and reliable handling of file and stream inputs. It is not intended as a standalone archiving solution but as a foundational helper for `archiver` itself.

npm install archiver-utils
INSTALL
IMPORT
SIG · ARCHIVER-UTILS
A
archiver-utils
datajavascriptv5.0.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

fs
import { fs } from 'archiver-utils';
const fs = require('archiver-utils').fs;
The `fs` object contains utilities like `walkdir`. Named import is preferred for ESM, but CommonJS `require` is also supported for Node.js environments.
stream
import { stream } from 'archiver-utils';
const stream = require('archiver-utils').stream;
The `stream` object includes utilities such as `detect` for identifying stream-like interfaces. Named import is standard.
buffer
import { buffer } from 'archiver-utils';
const buffer = require('archiver-utils').buffer;
The `buffer` object provides buffer-related utilities, such as `isBuffer`. Named import is standard.

Demonstrates how to use `fs.walkdir` to recursively traverse a directory and log file/directory information, then cleans up.

import { fs } from 'archiver-utils'; import { fileURLToPath } from 'url'; import { dirname, join } from 'path'; import * as nodeFs from 'node:fs'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); // Create a dummy directory structure for demonstration const tempDir = join(__dirname, 'temp_walkdir_test'); const subDir = join(tempDir, 'subfolder'); nodeFs.mkdirSync(subDir, { recursive: true }); nodeFs.writeFileSync(join(tempDir, 'file1.txt'), 'Content 1'); nodeFs.writeFileSync(join(subDir, 'file2.txt'), 'Content 2'); nodeFs.writeFileSync(join(tempDir, 'another-file.js'), 'console.log("hello");'); console.log(`Walking directory: ${tempDir}`); fs.walkdir(tempDir, (filepath, stats) => { if (stats.isDirectory()) { console.log(`[DIR] ${filepath}`); } else { console.log(`[FILE] ${filepath} (size: ${stats.size} bytes)`); } }, (err) => { if (err) { console.error('Error during walkdir:', err); } else { console.log('Walkdir complete.'); } // Clean up the dummy directory nodeFs.rmSync(tempDir, { recursive: true, force: true }); console.log('Cleaned up temp directory.'); });
Debug
Known issues
breakingVersion 5.0.1 and above dropped support for Node.js v12. Ensure your environment uses Node.js v14 or newer to avoid compatibility issues.
fix
Upgrade your Node.js runtime to version 14 or higher. The current recommended minimum is Node.js 14.
affects: >=5.0.1
breakingVersion 4.0.0 dropped support for Node.js v10. This was a significant breaking change requiring environments to upgrade to Node.js v12 or newer.
fix
Upgrade your Node.js runtime to version 12 or higher. For current releases, Node.js 14+ is required.
affects: >=4.0.0
gotchaThe `stream.detect` function was improved in v5.0.2 to allow for more general Stream-like interfaces. If you were relying on specific, stricter detection logic from older versions that might have excluded certain interfaces, this change could alter behavior.
fix
Review any custom stream detection logic in your application to ensure it aligns with the improved detection mechanism in 5.0.2. Test thoroughly if using custom stream implementations.
affects: >=5.0.2
gotchaDependency updates in v5.0.1, specifically `readable-stream` to v4 and `glob` to v9/v10, could introduce subtle behavioral changes or require different polyfills/usage patterns in specific environments.
fix
Check the changelogs for `readable-stream` v4 and `glob` v9/v10 if unexpected issues related to stream handling or file globbing arise after upgrading `archiver-utils`.
affects: >=5.0.1
Errors
Common errors & fixes
TypeError: (0, _archiverUtils.fs) is not a function
This error typically occurs when trying to destructure `fs` (or `stream`, `buffer`) from a CommonJS `require` call in an environment that expects named exports, or vice-versa with default imports.
fix
Ensure you are using the correct import syntax for your module environment. For ESM, use `import { fs } from 'archiver-utils';`. For CommonJS, use `const { fs } = require('archiver-utils');` or `const archiverUtils = require('archiver-utils'); const fs = archiverUtils.fs;`.
Error: The 'path' argument must be of type string. Received undefined
`fs.walkdir` (or similar path-based utilities) received an `undefined` or null path argument, likely due to an uninitialized variable or incorrect concatenation.
fix
Verify that the path variable passed to `fs.walkdir` is a valid string. Log the path before the call to debug its value.
ERR_REQUIRE_ESM: Must use import to load ES Module
Attempting to use `require()` to load `archiver-utils` in a context where Node.js has determined it should be an ES Module (e.g., in a package with `"type": "module"` or when importing a dependency that is ESM-only). While `archiver-utils` primarily supports CJS, conflicts can arise.
fix
If your project is an ES Module, switch to `import { fs } from 'archiver-utils';`. If the issue persists with other dependencies, ensure consistent module type usage across your project or use dynamic `import()` for CJS-only modules within an ESM context if absolutely necessary.
Upgrade
Version history
5.0.2latest on npm
Audit
Dependencies
readable-streamrequiredInternal stream handling and compatibility. Updated to v4 in 5.0.2.
globrequiredInternal file matching and path resolution. Updated to v9/v10 in 5.0.1.
Agent activity
29 hits · last 30 days
node
26
OpenAI (training)
1
Resources
archiver-utils — npm install archiver-utils · libregistry