My Favorite NPM Command
Let’s talk about my favorite npm command, npm repo.
Open package repository page in the browser - npm docs
This command is dead simple. Open the repository page for the given package in the browser. If you omit the package name, it will look at the local package.json and open that repository.
I use this command several times a day—often hourly. What’s great is that it works for published npm packages and any repo with a package.json. I’ll use it just to open the repo I’m working in, too. I don’t need a bunch of bookmarks or to hope that my current repo shows up on the GitHub homepage. I’ll just run npm repo and dig into any package, and I’ve yet to be rickrolled. Googling certain packages is annoying because you often have to add “GitHub repo” to the search.
History
The npm repo command was added in 2013 in commit 0223389 by TJ Holowaychuk, creator of Express, Mocha, and other popular npm packages. Ignoring various issues opened on the CLI, this is the only contribution he made directly.
Other package managers
The yarn cli does not have a repo command. Pnpm does not have a repo command, instead they forward the command to the npm cli among a list of other commands they forward. pnpm home is another good one they forward to npm, I just don’t usually reach for that one.
As I move further away from using Koa, Express, and TJ’s other legacy projects, I’m positive I’ll keep using npm repo. Praise TJ.