NPM vs Yarn: which package manager do you use?

madza profile image Madza ・1 min read

Two popular package managers in the ecosystem are NPM (Node package manager) and Yarn (package manager created by Facebook).

Which one do you use and why do you prefer it over the other?


markdown guide

Phew, I didn't know Facebook made Yarn. That makes me way less interested in using it, honestly.

I tend to use NPM just because my bash shortcuts are already set up for it, i.e. "d" for "npm run dev".

I guess it's mostly laziness, but all of my old projects already have package.json scripts that use npm so it seems silly to try to change for marginal speed benefits.


Yarn is totally compatible with the package.json file, you don't need a separate config file for it! The only difference is npm generates a package-lock.json file whereas yarn creates a yarn.lock file.

You execute your npm scripts by running yarn dev and installing packages to your package.json file is as easy as yarn add package-name.

It really doesn't matter much either way!


Facebook made React, React Native, GraphQL, and so on. I don't like Microsoft but can't live without VS code, Github, NPM.


Well Microsoft didn't MAKE Github nor NPM they jus bought it (github an so npm becomes part of it) so I'm not sure if it counts for that matter. Anyways too many people moved to GitLab and after experiencing some issues on Github I know why except for the fact they dislike MS. They do influence development of it so it might count.

As mentioned people still move away after such events but does it count as it would if they "made" it? For comparison Android was not made by Google but after buying it they controlled everyting (just my perspective of it might be incorrect), but MS didn't say they will write some Ruby to change the Github so does it really count?

Your perspective is right they acquired other companies because that will make more profit to their ecosystem.

Developers don't have a trust issue with Apple even though their products are closed source and then don't even contribute anything. And Microsoft has contributed to Linux kernel so any way we are going to have to use it. I believe its good if it's opensource.

Anyway, Competition is good npm is the best of itself because of yarn (caching and security).


Facebook has a lot of great open source projects, and great minds behind them! Why did it make you less interested?


Trust issues I would guess. Although it's open source it might contain code which you morally disapprove. Example: some people get the base code of VS Code(forgot the name)
then build it themselves which is different from what you get if you install their /MS version.

Would you mind elaborating? This is interesting. What code does VS Code have that is morally questionable?

You'll have to research for more details but in short, if you download "binaries" you'll get stuff that measures metrics and such and sends them back to MS, which I'm not sure is morally bad sice you click that agree. You have multiple posts of this one.


When I started learning to code, I liked Yarn over NPM because it felt like it exposed more of what was happening in the background in a more digestible way.

It would be interesting to know what some of the fundamental differences are tho.


For me doesn't really matter which one to use as long as the real problem exists which is the node_modules folder, unfortunately after over a decade of NodeJs this problem still isn't fixed, why should I have more than 30k of dependency files for every simple Create-React-App app, why there is not a centralized dependency management solution like C#, Currently I have a few React and Angular projects and the size of node_modules folders are almost 5GB and millions of files, I know there are some solution for this like PNPM but they are not without problems and also not as straight forward.


I only use Yarn because of recommendations I received regarding speed, and I really saw some difference there. But honestly never had any problem with NPM and the projects I started on NPM I kept it. If anyone could share a source with a bit more details on how each really differ from the other I'd appreciate.


My preference is to use npm because I have never really experienced that many problems with it. I have used yarn a few times and it feels like its almost exactly the same as npm. And because npm seems to have more usage I have just stuck with it for now. Unless I can see some real significant performance gains they seem to be more a less the same. It is like comparing React to Angular its just two different ways of doing the same thing.


This was exactly what I thought until I used yarn. Most of the tutorials and open source projects online use npm in their installations guides, so I assumed it was better. I now use yarn always because it’s much speedier and has nicer output.


I admit I've never used Yarn, NPM has always had all the features I've ever needed, although I admit I'm not a professional developer


I have recently tried yarn and liked it mostly for its speed and for its clear explanations of what is happening


Yarn! It's way faster and has much prettier output.


Yarn workspace is the game changer for monorepo.


I use npm because I'm lazy, but i reccomend pnpm.


Just took a look, and Yarn is faster, according to the benchmarks.


I am using it in my current project where we also implemented yarn workspaces, which is quite easy to maintain with yarn instead using it through npm.


I prefer yarn over npm because of the performance benefits
Performance while installing packages
As well as
Its commands are shorter, take less keystrokes to run


I prefer Yarn. Not sure why tbh. Feels a little cleaner to me. But I bounce between the two.