Earlier this week I needed a way to create zip files with node.js. I was shocked to find out that no such thing exists (prove me wrong interwebs!). Some hacks later, zipper was born:

Zipper, an insanely simple zipfile creator for node.js.

a zipper

a zipper by sogni_hal, on Flickr

Zipper has an API that consists of one method:

This method simply adds a file to your chosen zipfile, using an asynchronous operation. Full example:

Zipper is available on Github: https://github.com/rubenv/zipper
Or through npm: npm install zipper

  • Graham Lyon

    I smell overhead – if I wanted to add multiple files to a zip archive would this rebuild the archive each time a file is added?

  • Stoffe

    Can it handle adding multiple files, and more importantly, does it handle adding them in a directory? Could really use a simple zip creator, but it needs hierarchy. :)

  • http://www.savanne.be/ Ruben

    Multiple files currently means multiple subsequent calls. If this means a full rewrite of the file largely depends on the underlying architecture of libzip. Definitely room for improvement there, which will probably be quite important if you need to zip up large files.

    This wasn’t the case for us yet. In the future I’d like to move to a model where we can stream out zip files rather than working through the filesystem.

  • http://frugalcoder.us/ Michael J. Ryan

    Any chance of adding 7z support?

    • http://www.savanne.be/ Ruben

      Probably not, zip was chosen because it works for all users and OSes. 7z is slightly less supported out of the box.

  • Diego

    Got this :(

    C:\Temp\SikuliHS>npm install zipper
    npm http GET https://registry.npmjs.org/zipper
    npm http 304 https://registry.npmjs.org/zipper

    > zipper@0.1.1 install C:\Temp\SikuliHS\node_modules\zipper
    > node-waf configure build

    ‘node-waf’ is not recognized as an internal or external command,
    operable program or batch file.

    npm ERR! zipper@0.1.1 install: node-waf configure build
    npm ERR! cmd "/c" "node-waf configure build" failed with 1
    npm ERR!
    npm ERR! Failed at the zipper@0.1.1 install script.
    npm ERR! This is most likely a problem with the zipper package,
    npm ERR! not with npm itself.
    npm ERR! Tell the author that this fails on your system:
    npm ERR! node-waf configure build
    npm ERR! You can get their info via:
    npm ERR! npm owner ls zipper
    npm ERR! There is likely additional logging output above.
    npm ERR!
    npm ERR! System Windows_NT 6.1.7600
    npm ERR! command “C:\\Temp\\SikuliHS\\\\node.exe” “C:\\Temp\\SikuliHS\\node_modu
    les\\npm\\bin\\npm-cli.js” “install” “zipper”
    npm ERR! cwd C:\Temp\SikuliHS
    npm ERR! node -v v0.6.18
    npm ERR! npm -v 1.1.21
    npm ERR! code ELIFECYCLE
    npm ERR! message zipper@0.1.1 install: node-waf configure build
    npm ERR! message cmd "/c" "node-waf configure build" failed with 1
    npm ERR! errno {}
    npm ERR!
    npm ERR! Additional logging details can be found in:
    npm ERR! C:\Temp\SikuliHS\npm-debug.log
    npm not ok

    • http://www.savanne.be/ Ruben

      Looks like a problem with building on Windows. I haven’t tested that so I’m not surprised that it breaks. Not supported unless somebody contributes the right bits.