So I tried Yarn, yet another new JavaScript tool

Picture by

Recently Yarn (the new JavaScript package manager developed by engineers at Facebook, Google and Tilde) emerged as an alternative to npm.

The main argument for me to give it a try was that it was presented as fast (first word on the website and the GitHub) and it seems to be, I always found npm slow, maybe that’s because I am also a Spring developer using Maven and I’m tired of drinking my coffee while looking at the dependencies being downloaded before I can make a Hello World with my favorite oversized framework.

Repetitive tasks like downloading dependencies, building, linting, runing tests, … need to be the fastest possible, and trying Yarn follows that logic.

To every JavaScript developer thinking as I did “A new tool.. again… yay !”, don’t worry, it’s actually pretty straightforward, it’s just another package manager, you know how it works, so basically all you need is to know how to init a project, add dependencies, download them, and you’re good to go.

How to install Yarn

Personnally, I installed it through npm but they have a lot of possibilities in their installation guide.

$ npm install -g yarn
$ yarn --version # should give 0.16.1 at the time of writing

How to init a project

$ yarn init

You’ll have to answer a few questions exactly like npm does with npm init, and it will create the package.json file for you, nothing new, moving on.

For the name of your project, npm only allows URL-friendly characters (no spaces, …), Yarn doesn’t complain, BUT will error when you’ll try to add a dependency.

How to add a dependency

$ yarn add angular # for the latest version
$ yarn add angular@1.5.8 # for a specific version
$ yarn add --dev gulp # dev dependency

Same as npm, the node_modules directory is created and angular is added.

(If you install Angular 1.5.1 and then Angular 1.5.8, only the 1.5.8 will be available, there is only one version of a package at a time).

How to upgrade a dependency

$ yarn upgrade angular

How to remove a dependency

$ yarn remove angular

How to download all dependencies

$ yarn install
$ yarn

As you can see, it’s the same as npm so far, a few differences :

npm install => yarn add
npm install --save-dev => yarn add --dev

Yarn also has an offline mode with the --offline switch, it will look up the local registry and take the dependencies from here if it’s been already downloaded, a little feature that can come in handy.


I’m using Yarn in my new side project, and so far I like how fast it is, it’s not less easy than npm to use, thus until it proves me wrong, I’ll keep using it over npm. In my opinion, if someone tells you about Yarn, yet another JavaScript tool, don’t yawn, Yarn :)

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.