Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What features of yarn are not yet available in npm v5.0?

npm v5.0 brings a lot of features currently present in yarn, including:

  • installs --save by default
  • package-lock.json will be automatically created (I assume the lock file ensures consistent installs)
  • automatic fallback-to-offline mode

From my understanding, what yarn offers in addition is parallel downloads (therefore faster download time). I don't see that mentioned in the npm blog post. Apart from this, are there other benefits to still using yarn?

like image 722
Dheeraj Vepakomma Avatar asked May 29 '17 13:05

Dheeraj Vepakomma


2 Answers

Yarn is still, as of writing, slightly faster than npm. Thomas Schaaf has produced a comparison based on performance which can be viewed directly here. Currently, Yarn beats npm on every measurement, although not by a large margin. That's probably from the parallel downloads and superior caching, although that's purely conjecture and I haven't done any digging in the source to find out why the timing is different.

However, what you lose in performance, you gain in compatibility. There are a few packages that don't install correctly with Yarn, such as semantic-ui, so you'd need to use npm for that anyway.

Since npm is the canonical package manager for Node environments, most packages will have been tested to work with npm. The same can't be said for Yarn—it's still a relative outsider.

Overall, though, I think npm@5 is far better than its predecessors, and I think it'd be reasonable to "switch back" unless Yarn brings new features to the table, especially if compatibility with all packages is important to you.

like image 67
Aurora0001 Avatar answered Oct 13 '22 03:10

Aurora0001


That's a good question!

Indeed npm was pushed to have all these features yarn offers. Now they are pretty much the same:

  1. cache is totally rewritten, it even works offline
  2. --save is enabled by default
  3. package-lock.json locks your versions and it is not optional as it were with npm shrinkwrap

npm@5 also made a good progress at speed, but yarn is still faster. Here are the simple figures. Let's test it with vue-starter which has around 850 packages to download. npm’s time was not bad at all with 42 seconds at the fresh run. When the cache is ready, it takes only 30 seconds to install everything.

Compared to yarn: 35 seconds without cache and 20 seconds with the cache in place. For me, this time gap was important enough to still use yarn as a primary tool.

Actually, I wrote an article which covers all these topics: https://medium.com/wemake-services/is-yarn-still-a-thing-3c6886410c83

like image 45
sobolevn Avatar answered Oct 13 '22 05:10

sobolevn