Yarn? NPM? What??!!
Trying to learn some programming and got your head spinning about what a ball of thread has got to do with it? And then some programming tutorials seem to forego the ball of thread and use NPM? What?
What is NPM? (and Node)
NPM is short for Node Package Manager. So it lets you manage packages for Node. Simple. Now what Node (aka Node.js) is, that is another question. Try reading about it here. In short, it’s a runtime environment for JavaScript. Meaning, it enables you to run your JavaScript code.
Now what does it mean to manage packages?
Different people create packages, which are bundles of code that you can use in your application to add useful functionalities. Eg, if you are building a calculator app, you could use an existing package to add numbers (instead of writing all that code yourself). Or, if you are building an app to save files, you could use a package to save text to a PDF file. Before you can use these packages, you’ll need to install them in your computer, right? And you may want to upgrade them as newer versions become available. At times, you may want to remove some packages, etc. etc.
With NPM, you can install, uninstall, upgrade etc. (basically, manage) these different JavaScript packages that you can use to build your Node application.
So then what is Yarn?
Well, Yarn is also a package manager. Just like NPM.
They’re the same?!
Well, almost! Kinda! Not really! (You choose the phrase you like)
You can use Yarn, just like you can use NPM, to install, uninstall, upgrade etc. different packages. But you type in slightly different commands. Eg, to install a package called express, with NPM you would use the command npm install express
. To do the same thing with Yarn, you would use yarn add express
.
There are other differences (and also some similarities) between their command syntax. And there are also differences in terms of security, speed, etc. This article provides some good info.
So that’s it.
Yarn isn’t a ball of thread afterall. Install it, so that it can help you install other useful stuff. Or, install NPM.