The biggest difference here is that distros vet their maintainers, often with a lengthy process similar to hiring someone at a company, while NPM and similar repos are entirely self-serve, where anyone can register an account and just publish whatever packages.
This is very surprising to me. During the debacle over Rust in the Python cryptography package maintainers were saying it's unreasonable to expect them to read dependency changelogs.
They do not provide precompiled files for everyone and suddenly gcc isn't enough to build.
Debian (and I guess ubuntu) are stuck on a year old version because of using rust before packaging rust stuff has been solved.
They aren't the most careful of maintainers, it seems.
It was end users of the package that didn't know, had a dependency like "<=X" and with the big change in a minor version got the rust version they could not compile (and thus run).
On the plus side it gave the impetus for Python to define wheels for musl and other arch’s which is a nice outcome.
The AUR wants a word :)
If I wanted to do my own work I'd go back to Gentoo. ;)
Mostly because UNIX programs don't actually call other programs all that much. Composability happens on the shell level, but not so much in the program code level.
e.g. The implementation of 'cat -n' isn't 'cat | pr -n' or the equivalent C, and pr usually isn't in a separate package from cat.
The other point is that GNU utils are self-contained binaries and don't usually include transitive dependencies 20 levels deep.
Even when the problems these packages solve are not 100% trivial, unless you trust that library to be continuously maintained, maybe consider not adding the dependency, instead taking inspiration from the code and writing your own, maybe even simplified version of it (careful with that, you don't want to write your own crypto, for example - but when we're talking about a three-file "compare XML files" test util that hasn't been updated since 2014, just copying that code into your project might be the better approach).
[0]: And it really is JavaScript - I don't know of any other language with the same kind of explosion of micro-packages. I'm not saying that other languages never experience dependency hell - of course they do - only that it's usually not as horrifying as it is with JS.