
Next, create a directory called test and move into it: Next, install adm-zip with the npm install command:Īfter you run the command, npm will install adm-zip and update the package.json file. The -y option creates a default package.json file. Inside the directory, create a package.json file to manage the project dependencies: Navigate into the newly created directory with the cd command: You’ll archive this directory in the next section.Ĭreate a directory called zip_app with the following command: You’ll also create another directory containing text files and an image. This directory is where you’ll keep your program files. In this step, you’ll create the directory for your project and install adm-zip as a dependency. See the tutorial How To Work with Files using the fs Module in Node.js to review working with files. Knowledge of how to work with files in Node.js. Visit our tutorial Understanding the Event Loop, Callbacks, Promises, and Async/Await in JavaScript to learn the basics. Knowledge of how to write a Node.js program, see How To Write and Run Your First Program in Node.js.Ī basic understanding of asynchronous programming in JavaScript. Follow How to Install Node.js and Create a Local Development Environment to install Node.js. Node.js installed on your local or server environment. After that, you’ll add a file to an existing ZIP archive, and then finally, you’ll extract a ZIP archive into a directory. You’ll then list the ZIP archive contents. First, you’ll combine multiple files into a ZIP archive using adm-zip.

In this tutorial, you will use adm-zip module to compress, read, and decompress files. In Node.js, you can use the adm-zip module to create and read ZIP archives. The algorithm can reconstruct the data without any data loss. A ZIP file is an archive format that packs and compresses files with the lossless compression algorithm. To get around this, you can group the files into a single ZIP file. Some of these platforms have file size limits, and won’t accept large files.

Sooner or later you may need to transfer the files to other servers or upload multiple files from your local machine to different platforms. As your files grow in size, they start taking significant space on your hard drive. Working with files is one of the common tasks among developers. The author selected Open Sourcing Mental Illness to receive a donation as part of the Write for DOnations program.
