A QUICK SUMMARY – FOR THE BUSY ONES
TABLE OF CONTENTS
In the JavaScript ecosystem, adding a package to your project is as easy as running npm i
in your terminal. Package files are updated, the dependencies are installed, and we’re free to enjoy the bounty of the vast npm repository. Well, this might not always be the case—every package has its license, and a plethora of licenses place additional burdens on the developer. These might include requirements for attribution, open access to the source code, or even prohibitions on gaining financial benefits.
Each of these packages can also have several dependencies, which have their own licenses and dependencies, ad infinitum. If the issue of package licenses is considered from the start of the project or identified early enough, the liability can be minimized through reasonable selection and understanding of license requirements. In the case of legacy projects where no one considered this problem, the issue could be far larger.
This is why we developed a configurable tool focused on auditing project dependencies—License Auditor CLI, or LAC.
JavaScript projects use a variety of package managers, each with its own way of handling dependencies. To make LAC as universal as possible, we ensured it supports multiple package managers, including npm, yarn, and pnpm.
For npm, we leverage Arborist, a library designed to traverse and analyze dependency trees in a structured and efficient way. Arborist allows us to gather information on direct and transitive dependencies, ensuring we have a complete list of packages used within a project.
For yarn and pnpm, we take a different approach, utilizing their built-in commands to retrieve dependency data. Specifically, we use yarn list
for Yarn projects and pnpm ls
for pnpm-managed repositories. These commands provide structured outputs that allow us to extract relevant information about installed packages and their versions, ensuring that LAC can seamlessly analyze projects regardless of the package manager being used.
Once we identify all installed packages, the next step is determining their respective licenses. This isn't always straightforward, as licenses can be declared in multiple places within a package. LAC takes a comprehensive approach by checking the following sources:
license
field in their package.json
, making it the first and easiest place to look.While checking for LICENSE
and README
files, we employ text similarity calculations to recognize license texts even if they do not match predefined formats exactly. This helps us correctly classify licenses that may be expressed differently or contain minor textual variations.
One of LAC’s core strengths is its high level of configurability. Every project has its own licensing requirements, and we wanted to ensure that our tool could accommodate a variety of needs. LAC provides the following configuration options:
By offering this level of customization, LAC ensures that teams can audit their dependencies in a way that aligns with their internal policies and legal requirements.
To make License Auditor CLI as flexible as possible, we provide multiple output options. Users can choose to:
By supporting both interactive and automated workflows, LAC fits seamlessly into modern development environments.
As software projects grow in complexity, managing dependencies becomes an increasingly critical task. The risk of introducing legally problematic licenses into a project can be significant, particularly when working with large dependency trees. By using tools like License Auditor CLI, developers can take a proactive approach to license compliance, ensuring that their projects remain legally sound and free from unexpected obligations.
Through its comprehensive package analysis, flexible configuration options, and multiple output formats, LAC provides a robust solution to the challenge of dependency license auditing. Whether starting a new project or reviewing an existing codebase, staying mindful of software licenses is crucial—and with License Auditor CLI, it’s easier than ever.
Our promise
Every year, Brainhub helps 750,000+ founders, leaders and software engineers make smart tech decisions. We earn that trust by openly sharing our insights based on practical software engineering experience.
Authors
Popular this month