We recently installed Yarn as our dependency manager as an experiment. Despite the hype around Yarn, we weren’t expecting a dramatic difference in performance from npm. However, we saw the following results pretty much immediately.
Long story short–for us, Yarn lives up to its hype. At RapidAPI, we run npm install several times a day. Thanks to Yarn, we are saving a lot of time that allows us to accomplish more tasks and release faster builds.
Here’s a closer look at how installing Yarn impacted RapidAPI.
Facebook first built Yarn as a more scalable, consistent and secure alternative to npm. Facebook specifically wanted to address the following:
It was no small task–the npm registry sees up to five billion monthly downloads and has a user base of over five million engineers. But we were attracted to the speed and the fact that Yarn takes dependencies from multiple sources. That, and the fact that everyone we knew was talking about it.
After we decided to take a closer look, we were intrigued by how Yarn works under the hood. Yarn was born to solve the three main issues of npm:
Unlike switching from Grunt to Gulp, switching to Yarn was extremely easy. It uses the same package.json and node_modules and has super intuitive CLI.
After digging into these technical specifications, we were excited to get Yarn up and running on our system. For us, just running yarn did the trick.
That was it. The yarn CLI replaced nmp in our development workflow. The process was about as painless as it could be. If you do run into issues, Yarn has decent documentation on migrating from npm.
Our results were conclusive right off the bat. We saw…
We saw some users have issues with modules upon install, but we didn’t run into any problems.
The implications for RapidAPI are process-based. As an engineer, I’m always happy when things run more efficiently. Since we run npm installs several times a day, Yarn shaves off a decent chunk of time per build with little input. It’s not just us either. It looks like Yarn is running faster than npm across the board.
Overall, we deem this experiment a success.
Here are some of the pros/cons that we’ve found since switching from npm to Yarn.
Pros:
Cons:
Yarn is working well for us and we recommend it for most of the users. If you are working on Windows or installing packages directly from GitHub, it might make sense to stick with npm for now.
Syntax: Yarn is similar enough to npm that we haven’t experienced significant hiccups when working with it. We did find Infinite Red’s npm vs. Yarn Cheat Sheet extremely helpful when it came to navigating syntax. Yarn’s docs also have a CLI Introduction page with all of the commands listed.
Tutorial: If you’re familiar with npm, Yarn will be pretty self-explanatory. However, we found Samuel Oloruntoba’s tutorial on Scotch.io to be straightforward and comprehensive.
Anyone else make the jump from npm to Yarn? What was your experience? Tell us in the comments.
We're thrilled to announce the latest update to the Rapid Enterprise API Hub (version 2024.3)!…
Are you curious about what your API consumers are searching for? Is your Hub effectively…
The RapidAPI team is excited to announce the February 2024 update (version 2024.2) for the…
This January's release brings exciting features and improvements designed to empower you and your developers.…
Rapid API is committed to providing its users with the best possible experience, and the…
In today's fast-paced digital world, APIs (Application Programming Interfaces) have become the backbone of modern…
View Comments
Awesome post!
Thanks, Gant. I thought your cheat sheet was really helpful.
I wanted to replace npm with yarn, I installed it, but when executing the creation of a project in the command line with @ angular / cli, it still maintains the search of the dependencies using npm.
Fortunately, after the successful installation, the console sent me the following message:
Successfully initialized git.
Installing packages for tooling via npm.
Installed packages for tooling via npm.
You can `ng set --global packageManager=yarn`.
I Used this command "ng set --global packageManager=yarn"
this is very functional
sorry for my english...