Yarn is a new package manager recently open sourced by Facebook, created by a team of developers from Facebook with additional help from engineers from Google, Exponent and Tilde. Just to be clear, this is not a Facebook projects, it’s an open source, community project. It has a standard open source license, the same governance model as Ember or Rust and its own Github organization. You can also check out its website.
It’s compatible with the npm registry, replacing the existing workflow with something faster, more safe and more reliable.
What’s wrong with npm?
5 million engineers use the npm registry, adding up to about 5 billion downloads every month. It works well for all of them, but when you take into account the size of the codebase at Facebook and the number of engineers working together you start to have issues. The problems encountered were related to consistency, performance and security. Many facebook projects depend on the npm registry, but when installing dependencies on different machines they often encountered consistency issues. Fixing one problem in once place, created other problems somewhere else.
Trying to keep solving every issue as it came up turned out to be unproductive so they moved to build something new and suitable to their needs. The problems wasn’t necessarily npm, but the incompatibility between the workflow at Facebook and npm. Hacking around npm’s limitation wasn’t enough or practical for that matter.
Building Yarn
Yarn came as a direct response to the problems they encountered. Instead of keep trying to fix issues and invest in short term solutions they decided to build a new client that would meet their needs. As development began they realized that they were not the only ones facing the same issues, it became apparent that a new solution could help the whole community. That’s how Yarn came to be. With it you can access the npm registry but in a more secure and consistent environment.
Try out Yarn
npm install -g yarn
Yarn
The yarn CLI will replace npm in your development workflow with a matching command or a new similar command:
-
npm install → yarn. The yarn command will read your package.json, fetch packages from the npm registry, and populate your node_modules folder. It’s basically the same to running npm install.
-
npm install –save → yarn add . The invisible dependency behavior of npm install is removed and split the command. Running yarn add is equivalent to running npm install –save .
Tweet