DEV Community

Discussion on: The Difference Between NPM and Yarn

Collapse
 
lico profile image
SeongKuk Han

So, is yarn faster than npm in most cases? I wonder what advantages the serial installation process has. why does npm adopt it?

Collapse
 
patricknelson profile image
Patrick Nelson • Edited

Not sure. I just did a test between npm, yarn and pnpm and it seems that even though pnpm is still lighter weight and generally faster than npm, yarn is reliably fast (but varies depending on the versions of everything).

I'm leaving my benchmarks below but I realized partly why npm wasn't as fast was because I was on an older node version (so, npm version 6.14.16 in my case with yarn 1.22.17). You should definitely checkout this post for a far better breakdown though: blog.logrocket.com/javascript-pack...


For example, I got the following results testing each one (note that this was just a single benchmark for each package manager) so it's fairly anecdotal, however it's fairly typical of my experience.

Fresh install: (no caches)

  • npm 1m 23s
  • pnpm 50s
  • yarn 41s

Fresh install: (with caches)

  • npm 1m 7s
  • pnpm 32s
  • yarn 15s
Collapse
 
spicylemonhaha profile image
spicylemonhaha
Thread Thread
 
spicylemonhaha profile image
spicylemonhaha

59f86ef90 43be9d222 e906cdd98 #16633 npm now parallelizes tarball extraction across multiple child process workers. This can significantly speed up installations, specially when installing from cache, and will improve with number of processors. (@zkat)

Does npm indicate in this release note that it already uses parallel downloads

Collapse
 
spicylemonhaha profile image
spicylemonhaha

Since parallel downloads are faster than serial downloads, why hasn't npm changed the way that download dependencies after multiple iterations