What is a Package Manager in Software Development?

Deepak Kumar
3 min readJan 17, 2023

--

A package manager is a tool that is used to manage the external libraries, frameworks, or modules of a software project. It allows developers to easily install, update, and manage the various libraries and frameworks that a project depends on.

The most popular package managers are npm (Node Package Manager) for javascript projects and pip for python projects. Other package managers are yarn, composer (for PHP), gem (for ruby), and so on.

Almost every amateur or professional software developer has used a package manager to manage their software projects but why we use a package manager is still not clear to most of us.

There are several reasons why we use package managers:

  1. Dependency Management: External libraries, frameworks, or modules are known as Dependencies. Package managers make it easy to manage the dependencies of a project, ensuring that all the necessary libraries and frameworks are installed and up to date.
  2. Versioning: Package managers keep track of the versions of the libraries and frameworks that a project depends on, making it easy to revert to a previous version if necessary.
  3. Sharing and Reusing Code: Package managers make it easy to share and reuse code by allowing developers to easily install and use libraries and frameworks that have been created and shared by other developers.
  4. Consistency: Package managers ensure that all developers working on a project use the same version of the dependencies, which helps avoid inconsistencies and compatibility issues.

Let us understand why we use a package manager with a help of an example.

Typically, metadata of a project’s dependencies are stored in a file called package.json (for npm) or requirements.txt (for pip) at the root of their project. Then, developers can use the package manager’s command line interface (CLI) to install, update, and manage these dependencies.

To install a package called react-icons using npm, the developer would run the command npm install react-icons in the root of their project. Using npm update react-icons developer can update the package to the latest version, and to uninstall it would be npm uninstall react-iconsor npm remove react-icons.

Using those three commands a developer can manage a project’s dependencies. Generally, all these dependencies size up to more than 200MBs in a Node project with no external libraries.

Now suppose, you’ve to share your code with your coworkers or colleagues. It is not feasible to share the entire project of the size of more than 200MBs. What developers usually do is share the code which they’ve written without sharing all the dependencies as dependencies can be found on internet and can installed seperately with the help of a package manager.

The person who receives the shared code can install all the dependencies in their local machine just by using an install command in their package manager’s command line interface (CLI), npm install in case of a Node project.

Illustration of Package.json file containing all the dependencies
package.json

The package manager will look up for package.json file and look up the dependencies with the version needed to install in the local machine to run the project perfectly. Thus, a package manager helped us to manage our project efficiently and share our code with consistency as well as proper versioning.

In summary, package managers are a vital tool in software development as they make it easy to manage and reuse dependencies, ensure consistency and make the development process more efficient. Knowing how to properly use a package manager is an essential skill for any software developer.

--

--

Deepak Kumar
Deepak Kumar

Written by Deepak Kumar

Graduate Frontend Engineer at Doorpix | Sometimes Code, Sometimes Write. On a journey to live a better life | https://dazzlerkumar.vercel.app/

No responses yet