In 2021, should I use Yarn or npm?

Any project that uses JavaScript or one of its variations needs a package and script manager. For historical reasons, we have two options in common use: npm, the Node Package Manager, developed by npm, Inc (a subsidiary of GitHub, which is a subsidiary of Microsoft), is the standard one, installed along with Node; and Yarn, created by Facebook but currently developed by a regular open source community, is an alternative client for the npm system with a slightly different interface.

Yarn was created at a time when development of npm was in a rough patch. At the time, it had better performance, additional features, and provided more deterministic behavior. But npm eventually caught up, and now the differences are essentially only in interface.

Since npm comes with the Node installer, essentially everybody who works with JS (or one of its variations) has npm. Yarn has to be installed separately. And being the default, npm is used in most examples around the web.

Both are open source and hosted on GitHub (npm, Yarn). A quick look at the repositories shows npm is substantially more active in every metric.

In the end, as with most things in tech, you should use the best tool for the job, according to your project and your team. My recommendation is:

Hope that helped, thanks for reading.