Facebook has introduced Yarn, an open source JavaScript package manager that is more faster and more reliable as compared to current widely used npm. The company claims that the new package manage will reduce the installation times from several minutes to just few seconds in some scenarios — depending on the size of the packages you’re intended to install.

What is package manager?

As the name suggest, a package manager is a tool to manage the installation of packages — pieces of code that perform a particular task in the system — from a global code registry to developer’s local environment.

If we talk about JavaScript community alone, developers share hundreds of thousands of pieces of code with fellow developers to avoid rewriting basic components, libraries, or frameworks etc. Those pieces of code may in turn depend on other pieces of code, formulating a long chain of dependencies managed by package managers.

Developers around the world use package manage to automate the the installation, configuration, deployment, and management of libraries & frameworks as well as other software components. There are many package managers available for different languages like Composer/PEAR for PHP, RubyGems for Ruby, Maven for Java and pip for Python etc.

The most popular package manager for JavaScript is Node Package Manager(NPM), which provides access to more than 300,000 packages in npm registry. Over 5 million engineers use the npm registry and there are up to 5 billion downloads every month.

How Yarn works?

Yarn, developed by Facebook in collaboration with Google, Exponent and Tilde, claims to be a fast, reliable and secure alternative npm client. It is compatible with npm registry, but it takes different approach to install the packages — uses lockfiles and deterministic installation algorithm.

This allows it to maintain the same structure of node_modules directories for all users collaborating in a project, and help reduce bugs that are hard to trace and reproduce on multiple machines. Moreover, it also caches every package it downloads and uses parallel operations to ensure quicker and more reliable installation. Caching also allows it to work offline without an internet connection.

Additionally, Yarn is compatible with both npm and Bower workflows, and lets your restrict licenses of installed modules.

In some scenarios, Yarn is capable of performing 10 times faster than npm, according to Facebook. Sebastian McKenzie initially developed this project for internal use at Facebook, but it quickly gained popularity. Starting from this October, Yarn is now available for general public under a BSD license.

“After trying to solve for each issue as it came up, we set out to build a new solution to help us manage our dependencies more reliably,” said Sebastian McKenzie, Christoph, PojerJames Kyle @ code.facebook.com

Is Yarn the end of npm?

Yarn may get popularity in the short duration due to awesome features it has, and there will be many people switching to Yarn. But this is not the end of npm. Since npm is open source, anyone can fork the repository and can contribute it in order to satisfy their special needs. Perhaps, this is what the real motive behind the creation of Yarn, as its developers are significant contributors of npm as well.

> npm install -g yarn
> yarn

Read Kyle, McKenzie and Pojer’s complete blog post for more insight on Yarn’s history, architecture and installation process at Facebook Code blog. Yarn is also available on GitHub under a BSD-2-clause license. If you are using private packages, Yarn is not yet capable of working with them, however, this issue should be addressed in the following months.

If you like this article, please help us by sharing this article on your social media profiles and by spreading good words about Lhe.io. You may also want to follow us on TwitterGoogle+Linkedin and Facebook.

Like it? Share with your friends!


A passionate programmer, domainer, writer and photographer! Love writing about web development, latest trends in technology and domain name industry. Working hard to make the world a better place! Follow me at Twitter @attacomsian or visit my website www.attacomsian.com


Your email address will not be published.