You too can ace that coding interview
Get my guide for free
July 10, 2020

How to check NPM package availability

A CLI to account for package moniker rules

After hours of refactoring my code, renaming imports, demo site and repo, I realized I wasn’t allowed to publish that name on NPM. I did look for it and it showed up as non existant. It turns out there’re some package moniker rules I was not aware of.

In short, you aren’t allowed to publish if your package name differs by punctuation with an existing package. That is, you can’t use mydialogs if there’s another package named my-dialogs already.

You can then use the CLI name-exists to check for real NPM name availability:

npx name-exists <package-name>

It uses an offline snapshot of all the package names in the registry and compare your package name against them all.

Logo

I'm Carlos Roso. I'm a Software Engineer and digital nomad at Toptal. Previously Software Architect at Crossover. In love with open source and design.

More about me
Join the newsletter

I write about remote work, software and personal growth. Subscribe to enjoy my articles every once in a while.