David Gilbertson
Sep 3, 2017 · 4 min read

When I first read about Yarn, many moons ago, I thought hey, that’s neat. But I knew it wasn’t something I needed — like smart watches, or ‘friendship’.

As the months rolled by, I saw it showing up more and more in the install instructions for npm packages. Angular, Webpack, Prettier, Babel-loader, Bootstrap — all will inform you of the option to yarn add ...

I should be content to let the people be excited about the hot new thing. It’s really none of my business. And mind my own business I did, until I heard this: “we use Yarn because it’s more deterministic than npm”. I gasped, but luckily was able to cover my mouth in time so I don’t think they noticed.

For you see, that statement is not true. So, I thought it was about time for a blog post to counteract such misconceptions. Let’s start with a quote:

npm 5 has stronger guarantees across versions and has a stronger deterministic lockfile

That was the quote.

Who is this post for

Much like artichokes, this post is not for everyone. It’s for the developer using Node 8 (which comes with npm 5). The developer who has not read the Yarn and npm docs (you fools with your ‘social lives’). The developer who has heard about Yarn, seen it popping up in more and more places, and who has begun to think that they ‘should’ be using it.

Especially if you fit the above description and you didn’t know these things:

  • npm install works just fine offline*
  • npm install some-package updates package.json by default without appending --save
  • npm install some-package creates/updates package-lock.json by default

* I spent more time than I’m willing to quantify trying to work out how to get my computer into “Airplane mode” when it’s on a wired connection. Then I realised I could just unplug the cable.


On the flipside, if you can articulate the problems you face with npm, and these are the same problems that Yarn was built to solve, then happy days for you.

Or if you don’t need any of the features, but feel that saving x seconds when you run npm install is worth a whole new tool, then that’s your choice — I don’t have an opinion either way about your terrible decision.

What this post is not

It’s absolutely not bashing Yarn. Yarn solves the problems it set out to solve and does it well. And the good people that make Yarn have done nothing to suggest that it does anything more.

In fact, do you remember that quote from 236 words ago — the one about npm being more deterministic — that’s from the Yarn site.

Is there something wrong with using Yarn?

Yes there is, if you don’t need it.

It didn’t take me long to find an example of someone using Yarn for no good reason:

From some tutorial

That’s like saying, “next step, change the channel on your TV. You can either use the remote that came with the TV, or rig up a long stick with a bit of wire and a rubber nob on the end so that you can use it even if your remote’s batteries go flat. It’s totally up to you; they do the same thing. I’m going to use the stick…”


Some words about JavaScript fatigue

I would like to propose a unit of measure for the construct of ‘JavaScript fatigue’: the YAT.

A YAT is Yet Another Thing that you have to think about when you should really be busy writing code.

A nice simple web site that just needs some HTML, CSS and maybe some JS — that’s maybe 2 or 3 YATs.

A few years back, if you wanted to start a React site, you’d want Node and npm, and React, Babel (with some plugins/presets), Flux, and Fluxible too, (it’s 2015). Webpack, a few loaders for JSX, ES6, SCSS, etc. Maybe eslint, Mocha and Chai and Sinon and Istanbul.

Before you could even get started you were looking at maybe 15 YATs of fatigue and a lot of half-reading documentation. And not just for you, for everyone working on the project, including those poor, poor newbies. Won’t somebody please think of the newbies?

Then Facebook dropped Create React App and we were back to the good old days of one or two YATs. One minute you’re watching the news when a thought pops into your head: “hey, I could make an online game that shows three Presidential tweets and the user has to guess which one is real”. 20 minutes later you’re at your computer with a prototype well under way.

I like this world we’re currently in. Minimum setup time, maximum productivity. Life is good.

But it won’t stay this way if we don’t fight for it. And that means questioning all complexity in the tools that we use, and that’s what this post is about.

Don’t use things you don’t need.


OK I’ve lost interest in this post and I really want to go and write that Trump Tweet game.

Stay tuned…

[the pitter patter of Cherry browns]

Done.

https://trumptweetsquiz.firebaseapp.com

Go and play, try and get through all 20. If you’re anything like my focus groups you’ll be laughing at the start, bewildered in the middle, and sobbing by the end, wondering if maybe someone spilled beer on the matrix, and asking in a hollow tone if anyone is coming to clean it up.

Here’s the source, for those curious to see exactly how rubbish my code is.

HackerNoon.com

how hackers start their afternoons.

David Gilbertson

Written by

I like web stuff.

HackerNoon.com

how hackers start their afternoons.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade