[fa icon="calendar"] Publié le 16 November 2016 par Thibaut Cheymol
package.json file and install them in the
- 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.lockthat 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.
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
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
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?
Want to rate this article?☆☆☆☆☆ Submit Rating