DEV Community

Cover image for Are you a YARNer or a NPMer?
Charlie Say
Charlie Say

Posted on

Are you a YARNer or a NPMer?

An age old debate about package managers

Each have their pros & their cons

I personally prefer Yarn - I think it's general installation of packages is quicker and I REALLY appreciate its peer dependency resolution it saves LOADS of time.

So - what is your go-to package manager and why?

Top comments (77)

Collapse
 
gktim profile image
gkTim

pnpm really fast installation ( in one monorepo I have 2,5 min vs 20 min in npm) and stricter in resolving dependencies. Also saves a lot of disk space if you have multiple projects.

Collapse
 
randwulf_magnus profile image
Randell Knight

I also use and enjoy pnpm. It's great for strictly resolving dependencies across the board, instead of recreating the wheel.

Collapse
 
andrewbaisden profile image
Andrew Baisden

Is it really that good would you ever go back to npm or yarn? Or do you still use them sometimes?

Collapse
 
gktim profile image
gkTim

If I can choose I always choose pnpm. But try them all and decided for your self :)

Collapse
 
nikfp profile image
Nik F P • Edited

PNPM all the way, unless for some reason I have to use something else for some reason.

  • Install a dependency another project is already using on the same machine > FAST
  • Clear node_modules and reinstall > VERY fast vs others
  • Raw install in a CI worflow or fresh OS distro > usually faster than Yarn, always faster than NPM in my experience
  • Workspaces just kinda works. I fought with workspaces in NPM and had all manner of issues with they way things were hoisted, dependency versioning issues, and even VS Code not recognizing imports from dependency packages I was writing in the same Monorepo. All gone with PNPM
  • MASSIVE savings in disk space, since each dependency version is stored in a global cache once, and then linked in to each project. This is also why things install faster, if a dependency has been installed on the OS before, nothing gets pulled over the network.

Right now, PNPM is my only globally installed dependency. Everything else can be explicitly listed in each project without having to be reinstalled for each project, which has saved me from some CI headaches I ran into with NPM previously. (Like forgetting to list typescript, and having it work locally because of a global install but NOT work on CI because there are no global installs)

I know I sound like a fanboi, but its my happy place.

Collapse
 
kerrickchan profile image
Kerrick Chan

I heard NextJS has dependence graph problem.🤔 it good and fast but not fully support some old project🥲

Collapse
 
marblewraith profile image
Matthew Rath

NPM, because i'm lazy and it's the default.

Collapse
 
jimmyrleung profile image
Jimmy Rios Leung

this

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

I usually resolve the dependencies manually and download zips myself 🤣

Collapse
 
dillonb07 profile image
Dillon Barnes

Oh dear. I feel sorry for you. That must be a nightmare!

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

I have a dial up connection which makes it even worse!

Collapse
 
kwiat1990 profile image
Mateusz Kwiatkowski

A true old school hardcore developer! 😂

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

I joke but I can remember doing this! So many zip files, I can remember also when .min.js was a new choice!

Thread Thread
 
kwiat1990 profile image
Mateusz Kwiatkowski • Edited

Adam, I know and I can definitely relate, which makes it even funnier 😆.

Thread Thread
 
adam_cyclones profile image
Adam Crockett 🌀

I hope people don't feel bad for us being old 😂

Collapse
 
tmills9208 profile image
Tyler Mills

Neat, sounds very manual :p

I can think of using this for c++ or so, but im curious.

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

It's only a joke, this is what they both do.
CPP has some package managers already I think, Conan or something, but there is no standard "package" last time I was working in CPP anyway

Thread Thread
 
tmills9208 profile image
Tyler Mills

I see :p

and good to know as well, I do plan to start looking into vsti development (synths and such for DAWs) which mainly uses c++

Collapse
 
ederchrono profile image
Eder Díaz

ni-er?
github.com/antfu/ni
I've so many projects with yarn, npm and pnpm that I always forget which project uses which. It is great to just run nr dev to turn on the dev server and start coding right away

Collapse
 
hmphu profile image
Phu Hoang

Yay!! I’m agree with you

Collapse
 
ivan_jrmc profile image
Ivan Jeremic

Never bet against the platform, I was full into yarn but since npm has now all yarn features even the commands are same there is no need for yarn anymore all my projects just feel super clean now working directly with npm. If you still on yarn I recommend try going back to npm it is awesom.

Collapse
 
fish1 profile image
Jacob Enders

NPM, because it has more community support. I'd rather have more compatibility between my tools rather than save 10 minutes on an installation I only do a few times a year.

Collapse
 
franciscomendes10866 profile image
Francisco Mendes

Between NPM and Yarn I prefer Yarn for having more intuitive commands in my opinion. Nowadays I don't think there are any big differences in performance between the two anymore, I think yarn should still win because of the cache. Because if it's a clean install, they're very close.

I've been using pnpm lately and I've found it super interesting and I've been loving it.

Collapse
 
brianburton profile image
Brian Burton

npm primarily because yarn increases our app build times by 50% causing them to time out. We have a complex NextJS app that with npm takes ~6.5 minutes to build on a 32GB machine. yarn pushes that past our 10 minute sanity limit.

Collapse
 
rrsai profile image
Roy R.

One thing to note is yarn 3 has zipped and thus trackable dependency cache, if that were something that would work for you.
No more network connection issues making your app unbuildable, or package maintainers taking their packages away leaving you with a broken app.

Collapse
 
brianburton profile image
Brian Burton

That sounds cool, just not sure how that would work in an automated build environment within a Docker container. Where does the cache get stored?

Thread Thread
 
kzqai profile image
Coco Ronalds

git add .yarn/
git commit

You can just track it in git along with your source files.

Thread Thread
 
brianburton profile image
Brian Burton

Cool! I'll check it out. Thanks!

Collapse
 
raguay profile image
Richard Guay

npm is the one I use. I just never got around to trying out yarn or pnpm, but I’ve used yarn once to compile a repo that was based on it. But, I use mask to run the tasks in npm and external moving things around or setting up the compile with other command line commands.