Felicia is now known as NPM and nurse is known as Yarn

Bye NPM, Hello Yarn.

If you haven’t heard of Yarn you are missing out. Yarn is the new node package manager that the cool kids are using these days. Don’t you want to be a part of the cool kids? I know the label cool kids can be a misnomer and a term that can bring up bad school memories. However I ask you to push those negative thoughts to the side and come over and check out Yarn.

I will admit I haven’t had a whole lot of experience using the Yarn package manager, but I will tell you a few things that drew me towards using it in my own personal pet project and would even take the risk of persuading others to use it as well.

I will start with the most attractive feature, in my own opinion, is the folder management. If you are currently using NPM for your project take a look at the node_modules folder in the root of your project. If you take a few minutes and go through a few packages you will find another node_modules folder within a package. If you look inside that node_modules folder chances are you will find another package that contains a node_modules folder. And if you look inside that node_modules folder… I’m sure at this point you get the picture. This creates a very messy and complex folder structure. Also, side note for all you Windows users, you may run into the filename character limit.

Yarn untangles the messy folder structure and puts all the packages that are needed in the root of the node_modules folder. When you look inside of each package using Yarn you will not see another node_modules folder.

Second, parallel processing of dependencies. Instead of waiting for one package to finish downloading before the other one starts, all dependencies download at once. Even if one dependency fails it will retry again. This is pretty cool in my opinion and is something that has been needed for over a long time. So great job Facebook and Google for making this feature happen.

Third, the transition from NPM to Yarn is a breeze. All I had to do was type two commands

npm install -g yarn
yarn

and viola I had yarn implemented into my project. As Yarn was doing the transition from NPM it showed me several warnings that indicated my packages were out of date. Updating those packages were easy as well.

Bonus and probably the most important reason why I am writing this post is the speed at which my application runs. My personal pet project uses EmberCLI. Whenever you are first starting this tool on your machine it takes a few seconds to get the build to complete. Before, using NPM, it took around 11 seconds to build. Granted this is a very small application that is around 143MB. I know what you are thinking here with the size, but trust me the EmberCLI creates a very large project for such a small application during development. I would like to see what the size of the project when it’s ready for production. Anyways, with Yarn it now takes 8 seconds to build. A three second decrease may not seem much, but if you are working on a large project your build times will decrease on a more dramatic scale. Less time waiting for builds means more time for development.

Double Bonus for all you people still developing on Windows machines. One, I have a heart for you and would first tell you out of respect to consider switching to a Mac. However, with that being said, I know many of you will not for various reasons. I do really respect that, because I used to be one of you. In the meantime you would really be doing yourself a disservice by not switching over from NPM to Yarn. Whenever I was developing a web application using my old Windows machine it was evident to me that it took some time to create a build from Grunt, Gulp and/or EmberCLI. These build managers were taking a tremendous toll on my machine in time and how hot the machine ran. I cannot guarantee that your Windows machine will not run hot during these builds, but I can guarantee that it will be a faster process. The speed and efficiency gained is worth the minimal effort in creating a faster development environment.

Leave a comment