Setting Up & Using Yarn

Jack Whiting
2 min readDec 21, 2016

--

Yarn Logo https://yarnpkg.com

If you haven’t heard of Yarn before, it is a Package Manager for JavaScript (which replaces the existing workflow used with the NPM client). Yarn shares a similar workflow, but puts security, speed and reliability at the forefront.

Why Yarn Over NPM?

So, what makes Yarn better than just carrying on using NPM?

Speed, Yarn caches packages so it doesn’t need to downloaded it again and again. It also runs the process parallel so the runtime is a lot shorter. Bonus, you can install packages once they’ve been cached without an internet connection.

Security, Yarn uses checksums to ensure the integrity of all packages.

Reliability, Yarn uses a detailed lock file format, this ensures that if your install works on one system it will perform exactly the same on any other system that utilises Yarn.

Installing Yarn Globally

We will need to use npm for this one, to install Yarn globally, run the following command in terminal..

npm install -g yarn

Installing Packages

When you want to install a package, you can use a variation of the following command..

yarn add gulp --dev

This would be similar to running the following with NPM..

npm install gulp --save-dev

For a full list of commands take a look at the CLI docs on Yarn’s official website.

Article originally written on Jack Whiting’s Blog

--

--

Jack Whiting

Freelance Web Developer living in Nottingham, UK. Lover of JavaScript & PHP. Sharing my stumbles and findings.