Registry / storage / zip-bucket

zip-bucket

JSON →
library2.0.0jsnpmunverified

A Node.js library for creating .zip archives from files in a Google Cloud Storage bucket. Version 2.0.0 splits out the CLI tool into a separate package (zip-bucket-bin). It provides a Promise-based API with streaming support to handle large files efficiently. Alternative to manually downloading and zipping GCS files, with options to save locally, upload back to GCS, and rename files via a mapper function. Known for potential write stream timeouts (~1%) on large uploads.

npm install zip-bucket
INSTALL
IMPORT
SIG · ZIP-BUCKET
Z
zip-bucket
storagejavascriptv2.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

zip-bucket
import zipBucketFactory from 'zip-bucket'
const zipBucket = require('zip-bucket')
Library exports a factory function that takes a storage instance. Default import is correct; CommonJS require without calling is a common mistake.
factory with storage
const zipBucket = require('zip-bucket')(storage)
const zipBucket = require('zip-bucket')
The require returns a function, not an object. Must immediately invoke with storage instance.
TypeScript types
import zipBucketFactory from 'zip-bucket'
No official TypeScript types; types are not shipped. Use any declarations or @types if available.

Demonstrates how to zip files from a GCS bucket and save the archive locally using zip-bucket.

const {Storage} = require('@google-cloud/storage'); const fs = require('fs'); // Initialize GCS const storage = new Storage({keyFilename: process.env.GCS_KEYFILE ?? ''}); // Import zip-bucket and pass storage instance const zipBucket = require('zip-bucket')(storage); // Zip files from 'my-bucket' folder 'data/' and save to 'backup.zip' zipBucket({ fromBucket: 'my-bucket', fromPath: 'data/', keep: './backup.zip' }) .then(result => { console.log('Zip created successfully. Manifest:', result.manifest); }) .catch(err => { console.error('Error:', err); });
Debug
Known issues
breakingCLI tool moved to separate package in v2.0.0. The zip-bucket-bin package must be installed for command-line usage.
fix
Install zip-bucket-bin: npm install -g zip-bucket-bin
affects: >=2.0.0
deprecatedrequire('zip-bucket')() pattern is still supported but the factory function may be removed in future versions.
fix
Use const zipBucket = require('zip-bucket')(storage) or const zipBucketFactory = require('zip-bucket'); const zipBucket = zipBucketFactory(storage);
affects: >=2.0.0
gotchaWrite stream timeouts (~1% chance) on large uploads to GCS can cause promise rejections.
fix
Implement retry logic or catch errors and retry the zip operation.
affects: *
gotchaBandwidth fees may apply if running outside Google Cloud.
fix
Run the script on Google Cloud Platform (e.g., Cloud Functions, Compute Engine) to avoid egress charges.
affects: *
Errors
Common errors & fixes
TypeError: zipBucket is not a function
Missing invocation of the factory function returned by require('zip-bucket').
fix
Use require('zip-bucket')(storage) instead of require('zip-bucket')
Error: Cannot find module '@google-cloud/storage'
Missing required peer dependency.
fix
Install @google-cloud/storage: npm install @google-cloud/storage
Error: The API returned an error: Error: No bucket named '...'
Bucket name does not exist or is misspelled.
fix
Verify the bucket name and ensure it exists in your GCP project.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
@google-cloud/storagerequiredRequired to interact with Google Cloud Storage; passed as dependency to zipBucket factory function.
Agent activity
30 hits · last 30 days
node
26
Resources
zip-bucket — npm install zip-bucket · libregistry