Yarn, why?

I assumed all developers have experienced this one moment at least once in their career. You know, that moment when you misplaced a single word in code and everything just breaks or doesn’t work? No? Well I’m part of that wonderful dataset then and I think it’s a perfectly normal mistake at 1 AM in the morning.

After installing Yarn (a nice little package manager) without issues. I decided to try out expo-cli which helps simplify the process of starting a project in React Native quickly for mobile. I decided I would install it globally, so that I can access it everywhere from the terminal on my machine.

First I tried:

yarn add global expo-cli

Guess what this did? Exactly what I didn’t want. See the Note part. TLDR: It added package names called global and expo-cli locally in the current directory, instead of installing expo-cli in a global environment.

Turns out the proper command was:

yarn global add expo-cli

Wonderful. Looking back at this right as I’m writing this down now, I would have loved to have that flag like a npm --global flag. Basically any other command line with dashes, like --version to make it more obvious. Oh well.