Comparing npm packages

Last modified: 4/11/2023

Javascript development is constantly changing and it seems like there is always a new package being released. With so many packages available, it can be overwhelming to decide which one to use for your project.

In this article, I’ll be going over some tips and tricks to help you pick the right package for the job.

1. Define your needs

Start by defining your needs and constraints. What exactly are you looking for out of the package? Do you have performance requirements that you need to keep in mind? What existing packages are you coupled to? Having a clear idea of what you’re looking for will make it easier to narrow your options. A primitive example is, if you’re building a vue app and looking for a component library, there’s no need to consider react-based libraries like Material UI

2. Find existing comparisons

Next, I recommend simply googling the options and a comparison. Take advantage of the work the community has already done, but keep in mind that the javascript landscape is constantly changing. Because of that, restricting the search results to the past year, or even 6 months, can be useful to avoid getting outdated information. For example, if you’re looking for a react datepicker component, you might find articles recommending the package react-dates. At one point, this seemed like a solid option because it was being backed by airbnb. But fast forward to the end of 2022 and ownership of the package has changed, it hasn’t received an update in almost 3 years.

3. Use automated online tools

Next, I recommend comparing the packages using online tools. The first tool I recommend is npmtrends.com. This allows you to plot downloads over time to give you an idea of how the popularity of a given package has changed over time and how it’s trending now. For example, for a framework comparison:

The second tool I recommend is npmcompare.com. This tool doesn’t give you as much of a historical perspective, but it does have some metrics that I find can be useful in your decision. In particular, I like to see more than 1 maintainer, a small, or ideally empty dependency list, and a small number of open issues. Maintainers and dependencies can be particularly important because it can decrease the points of failure in your app.

4. Take a look at the packages’ docs

I also like taking a look at the projects’ github pages & documentation. Things like predominantly typescript codebases and high quality docs and typically communicate better developer ergonomics for the library as well as greater commitment from maintainers. Taking a look directly at the package.json can also be useful if you’re concerned about compatibility issues with your node version or other packages.

5. Put together some proof of concepts

Finally, if time permits, I recommend actually putting together proof of concepts for any remaining close contenders, because that’s really the best way to know which will blend best with your app’s existing workflows & patterns.

Conclusion

And that’s it! With just a little research, you can easily compare npm packages and find the one that’s right for your project.

Hope you enjoyed the article and happy coding!