[fa icon="calendar"] Publié le 16 November 2016 par Thibaut Cheymol

Disclaimer: I love npm, it is so convenient. It makes your javascript application modular by installing any existing package in a breeze. However, I must admit that waiting for npm while it is installing all the dependencies is painful, especially when your project grows. But now, this long waiting time is no longer existing with Yarn.

What is Yarn ? 

Yarn is a package manager for javascript applications. As npm, it lists all your dependencies in a package.json file and install them in the node_modules folder

What is cool with Yarn ?

  • It is compatible with the npm registry.
  • The progress bar is smoother, and the output is cleaner (and includes emojis 😺).
  • It is freakingly faster because it generates a cache of the previously installed packages and run tasks downloading and installation tasks in parallel.
  • It creates a yarn.lock that you commit and ensures that everyone working on the project has the same version of every package. Unlike npm shrinkwrap that must be manually invoked, yarn updates this file itself every time a new package is added or removed.

How do I get started ?

Funnily enough, you can install yarn with npm:

npm install -g yarn

If you already have projects packaged with npm, you can replace all your npm install calls with yarn install

Now, when you need to add new packages, the syntax is a litle different

yarn add [package-name]

To create a new project, just run

yarn init

Now, on an example

On a React-native project I am working on, I did try installing the whole project node dependencies with npm and with Yarn. Here is the result:

  • Yarn : 37s
  • npm : 2m41s = 161s

This is Yarn output:


Ant there is npm output:

The winner is from far Yarn with 77% less time and a much more readable output.


At the end, there is almost no difference, except for a few commands to remember, between npm and yarn. Yarn is just really faster, so it's worth giving it a try !

Liked this article? Interested in building an app with us?

Contact a React Native expert in Paris

Want to rate this article?
Submit Rating

Topics: NodeJS