Hi Friends 👋🏼,
Out of my curiosity, what are the differences between npm
, yarn
and pnpm
? Which one do you use and why?
A while ago, many said that yarn
runs faster than npm
. But then, that's no longer the case. They both are the same -- in my opinion as a Windows user. But I'm not familiar yet with pnpm
.
Top comments (10)
I'd say...
Not my area of expertise, but that's my high level idea.
Thanks for the insights, Ben! 🙏😄
NPM also has a lockfile, but it's not enforced without using "npm ci" command.
And yarn will happily update the lockfile (like npm install) without --frozen-lockfile.
from what I've been told it's best to use pnpm, but you cant have it independently from npm, I think. basically, while npm installs every single dependency ever and makes your project bundle from like 1.5 or 2mb to 100 or 200 mb , pnpm will do the same. but the trick with pnpm is that it will do it just once, and not for multiple projects.
so yeah... what I've learned is - package managers are hell.
but one cant do without them.
pnpm is best
but as a windows user you may not notice the performance improvements (because windows ntfs throttles / scans for viruses all created and compiled source files - every time they are touched and/or read - and even if you disable/exclude the dir in your av)
in Linux/Mac the performance of pnpm is like
As a single dev on windows you may not care (for now), but you will - the moment you want to run it in any kind of cloud env or CI
Thank you! It's answering why I, as a Windows user, don't see major differences between them 😄
I use
npm
for its simplicity and popularity but yarn is good too.JS is just one language in the backend toolchain, folks often need to work with other package managers too like PHP's composer for backend scripting and Python's PIP for data science libraries. Eventually, all these package managers could be clubbed into one "global" package manager with single backend. Github is in the right position to do this and I think they're making some efforts along these lines.
In most cases I use pnpm because I see performance gains on my machine and many projects where I am involved use pnpm anyway.
Sometimes I use npm when project is really simple or I want to demonstrate something in guides/docs - npm is just always installed with Node.js so anyone who reads guide can easily follow steps.
Yep this is a good approach 👍 things are always changing in the JavaScript ecosystem!