DEV Community

TheOmniKit
TheOmniKit

Posted on

how do you pick an npm package name

okay so quick question for people who publish packages, how do you check a name before you create the repo and everything. because the worst way to find out is folder named, readme written, then npm says no.

the rules are not hard just easy to forget. lower case only for a new package, max 214 characters, cannot start with a dot or an underscore, only url friendly characters so "hello world" is out, and a core module name like http is refused for new ones too. the funny part is My-App with capitals is still allowed for an old package, because the rules came later and npm didn't break the old ones. so a name can be fine for old, not fine for new. same with http, old yes, new no.

and node_modules, that one is refused for everyone, no matter old or new.

i put these in a small checker on a site i built, so ya, i'm biased, it runs in the browser and you just type the name: https://theomnikit.com/dev/npm-package-name-checker?utm_source=devto&utm_medium=article&utm_campaign=devto-npm-name-question

it shows the same message npm gives, like "name can no longer contain capital letters". but i want to know what you do. do you just run npm view name and see if it 404s, or do you have some script, or you just try publish and see? and scoped names, do you always go with @yourname/ to avoid the whole fight? tell me, i'm curious what people actually do.

i used an AI assistant to help draft this, the facts are from the tool page.

Top comments (0)