...

/

Zipping Files

Zipping Files

Learn how to zip files together with Node.

Installing dependencies

Up until now, you have been making use of Node’s standard API library, such as the process, path, and os modules. If you want to extend your choice to use more libraries that provide further functionality, you can turn to npm. The npm ecosystem is huge and if you search for a library with certain functionality, chances are that you will find it.

Suppose a member of your team has requested that you zip up a text file and an image. To accomplish this, you will use an external dependency identified as: archiver.

Note: As you might recall from the previous lessons, for installing a dependency, you would normally need to run the npm install archiver in the terminal. This command will install the dependency into node_modules and add it to the project’s dependencies in its package.json file. However, you will not have to do this right now, as these dependencies have already been listed in the current project’s package.json file.

As a reminder, npm install looks at your project’s package.json file and installs all of the ...