{"id":49832,"library":"zip-bucket","title":"zip-bucket","description":"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.","status":"active","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/DrPaulBrewer/zip-bucket","tags":["javascript","zip","cloud-storage"],"install":[{"cmd":"npm install zip-bucket","lang":"bash","label":"npm"},{"cmd":"yarn add zip-bucket","lang":"bash","label":"yarn"},{"cmd":"pnpm add zip-bucket","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required to interact with Google Cloud Storage; passed as dependency to zipBucket factory function.","package":"@google-cloud/storage","optional":false}],"imports":[{"note":"Library exports a factory function that takes a storage instance. Default import is correct; CommonJS require without calling is a common mistake.","wrong":"const zipBucket = require('zip-bucket')","symbol":"zip-bucket","correct":"import zipBucketFactory from 'zip-bucket'"},{"note":"The require returns a function, not an object. Must immediately invoke with storage instance.","wrong":"const zipBucket = require('zip-bucket')","symbol":"factory with storage","correct":"const zipBucket = require('zip-bucket')(storage)"},{"note":"No official TypeScript types; types are not shipped. Use any declarations or @types if available.","wrong":"","symbol":"TypeScript types","correct":"import zipBucketFactory from 'zip-bucket'"}],"quickstart":{"code":"const {Storage} = require('@google-cloud/storage');\nconst fs = require('fs');\n\n// Initialize GCS\nconst storage = new Storage({keyFilename: process.env.GCS_KEYFILE ?? ''});\n\n// Import zip-bucket and pass storage instance\nconst zipBucket = require('zip-bucket')(storage);\n\n// Zip files from 'my-bucket' folder 'data/' and save to 'backup.zip'\nzipBucket({\n  fromBucket: 'my-bucket',\n  fromPath: 'data/',\n  keep: './backup.zip'\n})\n.then(result => {\n  console.log('Zip created successfully. Manifest:', result.manifest);\n})\n.catch(err => {\n  console.error('Error:', err);\n});","lang":"javascript","description":"Demonstrates how to zip files from a GCS bucket and save the archive locally using zip-bucket."},"warnings":[{"fix":"Install zip-bucket-bin: npm install -g zip-bucket-bin","message":"CLI tool moved to separate package in v2.0.0. The zip-bucket-bin package must be installed for command-line usage.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Use const zipBucket = require('zip-bucket')(storage) or const zipBucketFactory = require('zip-bucket'); const zipBucket = zipBucketFactory(storage);","message":"require('zip-bucket')() pattern is still supported but the factory function may be removed in future versions.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Implement retry logic or catch errors and retry the zip operation.","message":"Write stream timeouts (~1% chance) on large uploads to GCS can cause promise rejections.","severity":"gotcha","affected_versions":"*"},{"fix":"Run the script on Google Cloud Platform (e.g., Cloud Functions, Compute Engine) to avoid egress charges.","message":"Bandwidth fees may apply if running outside Google Cloud.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"search_vec":"'1':79 '2.0.0':20 'altern':49 'api':40 'archiv':10 'back':63 'base':39 'bin':33 'bucket':3,18,32 'cli':24 'cloud':16,86 'cloud-storag':85 'creat':8 'download':52 'effici':48 'file':12,47,56,68 'function':72 'gcs':55,65 'googl':15 'handl':45 'javascript':83 'known':73 'larg':46,81 'librari':6 'local':61 'manual':51 'mapper':71 'node.js':5 'option':58 'packag':29 'potenti':75 'promis':38 'promise-bas':37 'provid':35 'renam':67 'save':60 'separ':28 'split':21 'storag':17,87 'stream':42,77 'support':43 'timeout':78 'tool':25 'upload':62,82 'version':19 'via':69 'write':76 'zip':2,9,31,54,84 'zip-bucket':1 'zip-bucket-bin':30","created_at":"2026-06-07T17:03:50.119835+00:00","updated_at":"2026-06-07T17:03:50.119835+00:00","problems":[{"fix":"Use require('zip-bucket')(storage) instead of require('zip-bucket')","cause":"Missing invocation of the factory function returned by require('zip-bucket').","error":"TypeError: zipBucket is not a function"},{"fix":"Install @google-cloud/storage: npm install @google-cloud/storage","cause":"Missing required peer dependency.","error":"Error: Cannot find module '@google-cloud/storage'"},{"fix":"Verify the bucket name and ensure it exists in your GCP project.","cause":"Bucket name does not exist or is misspelled.","error":"Error: The API returned an error: Error: No bucket named '...'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/DrPaulBrewer/zip-bucket#readme","github":"https://github.com/DrPaulBrewer/zip-bucket","docs":null,"changelog":null,"pypi":null,"npm":"zip-bucket","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}