Nodejs: how to create a zip file with a existing file

Viewed 474

Is there a simple way of creating a zip file and add a file to it in nodejs?

I found tons of examples describing following:

var zip = new JSZip();
zip.file("Hello.txt", "Hello World\n");

What I need to do is

1. create a zip file
2. add an existing file, not a block of text 
3. save the file

I used to do this in python with following code

with ZipFile('myzipfile.zip', 'w') as zip_write:
        zip_write.write('myfile.txt')

what would the node's equivalent of creating an zip file and adding an existing file to it?

1 Answers
Related