npm — What is it, why its cool

Read here for the basic of basics on npm packages

Node.js logo

I do this that you, too, might be in the Node. No, I won’t stop, you stop. Photo by CopyrightFreePictures on Pixabay.

I recall when I first got into coding and was looking for helper tools, I saw people saying to “npm whateveritsname”, and I was totally lost. Hopefully you’ll be better off.

npm — Not Poorly Managed

At its inception, “npm” was an acronym for “node package manager”, and to a point that’s still what it does. Using a terminal (either in your code editor or externally), you can use npm to import packages with various uses into your code.

(Well, first you have to install Node.js from the Node.js website. And THEN you can get your mitt’s on those juicy, handy modules.)

But npm isn’t just about Node.js anymore. It’s a way to easily distribute files and packages of many kinds. Far and away, though, the main use is still to publish, discover, and install node modules, and ranks as one of the largest software registries in the world. Like it’s near-cousin GitHub, it’s moved somewhat beyond it’s original footprint due to just how convenient it is.

This is why the npm site itself jokes that “npm” doesn’t stand for anything any longer.

npm — The Benefits

In a word, it makes collaborative, cumulative development easy. Downloading from their repos is just a command line away, and sharing your work, or working with others, is simple and streamlined. Since projects connect with GitHub, version control is built in.

npm is also an invaluable resource to millions of developers who don’t want to reinvent the wheel for every project. If someone else has made something that gives you precise dates, or cool looking highlights, or handy helpers, or generates witty banter to display while your app is loading, why do that again yourself?

Node like image

Image these blobby little Christmas lights like all those millions of code packages that developers have already written for you. Pretty. Photo by Gerhard G. on Pixabay.

npm — The Module

The formerly-‘m’ part of npm, npm modules are the nifty way of passing functionality around. Since they’re, well, modular, they can be incorporated or excised smoothly as needed from larger projects. They work independently, and avoid interfering with other modules and mucking up your global scope.

npm — The Components

Broadly speaking, npm consists of three primary components.

  • The website
  • The Command Line Interface (CLI)
  • The registry

The website serves as a discovery tool. You never know what cool stuff people have programmed out until you see what’s there. There’s also lots of great finding tools beyond the search, like many categories (front end, back end, CLI, CSS, testing, and much more), the numerous stats, the number of dependencies (e.g. other modules that a module depends on) and the most recent version history that tells you how well-maintained a module is.

The CLI is where you download and upload things. Since developers of all stripes are already command-lining their lives away one line of code at a time anyway, this is by far the easiest and most smooth way to get the good stuff. Go to where the people are, they say.

The registry is the database of these modules itself. That’s what maintains version numbers, provides access to the modules, informs users of updates, and holds all the other metadata to track all those billions of downloads.

Seriously. Like, 27,998,093,209 downloads on the week this post was written.

So one or two people might be using it, and it’s probably pretty handy, and good to get familiar with, too.

Written on February 20, 2021