Just tried out Yarn and indeed it's mega-fast. After running yarn
in the console with a loaded package.json
, it installed everything. I then ran npm dedupe
expecting nothing much to happen since Yarn is so optimized, but it removed a ton of stuff. Is there some Yarn equivalent to npm dedupe
?
Addition:
As noted in my comment below, I thought perhaps yarn install --flat
might be an npm dedupe
equivalent as the Yarn documentation describes it as "installing one and only one version of a package". So I played around with --flat
and there's a couple things to note:
cannot find module
errors.npm dedupe
after doing a yarn install --flat
and it still resulted in a ton of removals. This was a surprise to me.So I'm taking it that npm dedupe
is doing some other magic under the hood and I'm just naive about processes that I need not be concerned with. Perhaps it's just best to leave the tree alone and forget about --flat
and dedupe
altogether.
It seems like even now Yarn doesn't do the greatest job of minimizing duplicate dependencies. Running yarn --flat
forces there to be only one version of a dependency even when they may not be compatible, so that's not ideal. You can use the yarn-deduplicate
package to minimize the number of duplicates, while still allowing some in cases where there are not overlapping requirements. yarn-deduplicate
also has a --fail
option which will return a non-zero (failing) status. This can be useful to run on CI to ensure that anybody who modifies dependencies doesn't introduce new duplicates.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With