NPM vs. Yarn, What’s the Difference?

NPM is a JavaScript package manager. NPM, the organization, is the worlds biggest software registry. NPM is used by the Open Source community to share software in the shape of packages. Packages can be shared publicly, and privately.

Yarn is a tool that is built on top of NPM. It was originally created by Facebook, to solve various dependency and caching issues involving NPM.

Both Yarn and NPM use the NPM registry to install software packages in your project. This means that if you want to install a fresh version of e.g. the Material UI framework, you can use either npm or yarn:

// with npm
npm install @material-ui/core

// with yarn
yarn add @material-ui/core

The result is the same.


Let’s discuss some of the advantages of Yarn over NPM.

Yarn is faster

The main advantage Yarn has over NPM, is speed. Yarn is faster is because it provides parallel installation of packages, while NPM installs one package at a time.

Yarn may be more secure

NPM used to have security issues involving how they managed dependencies installs and version control. Yarn solved this with the yarn.lock file which ensures that developers install the same package versions across different devices.

Note: since NPM5 was released, NPM also has a lock file, called package.lock which has improved version control greatly.


NPM and Yarn are much more similar than different in 2019. Yarn still edges out NPM in terms of speed, but other than that, my current impression is that it won’t make much of a difference which one you use. As long as you’re consistent, you’ll have a good time using either.

On a personal side note, I consistently have more problems using NPM than Yarn. I haven’t been able to make the Material UI framework update properly when using NPM, but it always works with Yarn. That’s just my personal anecdote, but it’s one reason that I still prefer Yarn over NPM. That might change in the future though.

For plenty of technical comparisons between Yarn and NPM, check out this great NPM vs. Yarn Cheat Sheet by Gant Laborde.

Has this been helpful to you?

You can support my work by sharing this article with others, or perhaps buy me a cup of coffee 😊


Share & Discuss on