The UpgradeJS Blog

Introducing Depngn

In the fast-paced world of software development, keeping track of dependencies and ensuring they are compatible with the latest version of Node can be a daunting task. This is where depngn comes in - a powerful CLI tool designed to help developers determine if their dependencies support a specific version of Node.

While implementing some features, you might find yourself needing to add third-party packages to your application, to prevent “reinventing the wheel”. It leads to faster initial development and, sometimes, easier scalability, but it may also lead to trouble while maintaining all of your dependencies. The more dependencies you have tightly coupled the more complex it will be for you to maintain them during the course of development if you don’t keep them up to date as much as possible.

Here at UpgradeJS, we created a tool to help us understand the dependencies’ compatibility and we would like to share it with the community.

The tool

Introducing: depngn (short for dependency engine). This handy tool allows us to determine the amount of work we need to do while upgrading any Node.js application.

True to our value of being Open by Default opens a new window , this tool is open to the community. You can find it here - UpgradeJS/depngn opens a new window .

The use case

Imagine that you started your business a couple of years ago, it was successfully growing, and you were focused on building new features all the time and not spending much time (or any time at all) on refactoring/reducing your technical debt. After some years your application has all the features you wanted, and from now on your main goal is to keep it working and to improve your code base so you have an easier implementing new features or identifying/fixing bugs.

The possible first step here is to upgrade the project to run on the latest Node version because, for example, the 14.x version will reach the “End-of-life” milestone in April 2023. You don’t want your project to use an unsupported Node version, and now you are wondering if your application will continue working on newer Node versions. Determining if your codebase is compatible with the desired version is a less complicated task than determining if your dependencies will work with that version.

Enter depngn.

Installation and usage

Using this tool is pretty straightforward, and you do not need to install it. You can run it just by using the npx tool:

npx depngn <node-version> [options]

npx depngn 18.13.0

npx depngn 14.17.6 --reporter=json

You can use your preferred package manager to add depngn to your project and use its API. For example:

npm i depngn

yarn add depngn

pnpm add depngn

For now, this tool supports analyzing only npm and yarn projects, but we plan to add support for pnpm as well. We have created an issue here opens a new window for community members who would like to participate, so feel free to contribute if you find this feature useful.

There are a couple of options for how to show the result of the analysis. You can specify a desired type using the --reporter argument with the following options:

  • terminal: default method, will output a table to the terminal. Table showing the output of the depngn execution with node v10 and v18
  • html: will create an HTML file that can be easily reviewed in the browser;
  • json: will write a file to the directory the command is executed in. It has the following format:
[package_name]: {
  compatible: boolean // whether or not this package will work with the given Node version
  range: string // the range of supported Node versions
}

Conclusion

As was mentioned earlier, we are open to the community, and you are more than welcome to contribute to our open source projects opens a new window , the depngn being no exception. If you found this tool helpful and have any suggestions or feedback, feel free to reach out to us!