DEV Community

Jacob Fromm
Jacob Fromm

Posted on

Things I'm Embarrassed I Don't Know, pt. 1

I'm a HUGE dumbass. I know a lot of developers probably feel this way; there's an ever-expanding universe of frameworks, languages, and libraries to learn; there's always someone better or more accomplished (often two completely different things) to compare yourself to; and if you're always learning, you're often swimming in confusion. But I really am (a dumbass, that is). I'm lucky to have a supportive community in which I'm comfortable being vulnerable and asking pretty dumb questions, but there are some topics that are just too embarrassing for me to ask even my closest coder friends. So I decided to start a series of Things I'm Embarrassed I Don't Know.

In this series, I'll be writing about topics I feel like I should've known by now. The, "how did I complete project X if I don't know convention Y?" type of things. I don't want to lose the respect of my peers, but strangers on the internet? Who cares! So, without further ado:

Things I'm Embarrassed I Don't Know

Part 1: Package Managers (npm vs. yarn)

Why I'm embarrassed to ask
I've used package managers in just about every project I've ever built, so you'd think I might have an opinion about which one to use. To me, building front ends and not understanding package managers feels like a cook not knowing how to peel garlic.

The Facts

npm
  • released in 2010
  • stands for "node package manager"
  • automatically installed when you download Node.js
yarn
  • released by Facebook in 2016
  • developed to address npm's shortcomings (at release time)
  • Yarn 2, released in January 2020, received widespread criticism from the dev community

The Differences

  • Yarn is slightly faster than npm, partially due to installing multiple packages at once, as opposed to npm's one-at-a-time approach to installs.
  • Yarn's terminal output is less verbose than npm's.
  • In the past year, npm has been downloaded over 600,000 times more than Yarn. Screen Shot 2021-02-07 at 8.59.13 PM
  • However, Yarn is much more popular than npm on Github
npm

Screen Shot 2021-02-07 at 9.02.31 PM

yarn

Screen Shot 2021-02-07 at 9.02.52 PM

The Similarities

  • Both package managers install packages into the node_modules folder (with the exception of Yarn 2)
  • Both provide package.json files. According to White Source Software: > This file keeps all the relevant metadata associated with the project. It assists in managing the project’s dependencies version, scripts, and more.
  • Both provide lock files (package-lock.json and yarn-lock.json, respectively). As defined by White Source Software: > The lock file ensures the same file structure in node_modules is maintained across all environments. This provides determinism, supports collaboration with other developers, and prevents code breakages from installing new or incompatible dependencies.
  • Yarn recently added a new feature to make it easy for users to transition from npm to Yarn.
  • npm 7, available now, allows for easier handling of yarn.lock files
  • Recent updates have brought npm's performance and security in line with Yarn's. #### The Upshot
  • These two package managers are quite similar, but pick one. Don't use them together. Although, with the latest updates, you probably could.
  • In general, both npm and Yarn manage packages——the dependencies and plugins you use in a software engineering project.
  • Don't let anyone make you feel dumb for using one over the other. For most devs, it's just a matter of personal choice.

Resources

  1. https://www.whitesourcesoftware.com/free-developer-tools/blog/npm-vs-yarn-which-should-you-choose/

Top comments (0)