Getting a great npm name

Francisco Donate 📝 Edit 🕑

You might be surprised to know that I am developing server.js under the npm name “server”, so I can direct users to just do npm install server. Wait, wasn’t this package taken already?

In fact it was; there was a 0.0.3 version published a few years back. But npm’s “Package Name Disputes” is pretty clear about it:

“Some things are not allowed, and will be removed without discussion if they are brought to the attention of the npm registry admins, including but not limited to: […] “Squatting” on a package name that you plan to use, but aren’t actually using. […] Putting empty packages in the registry.”

From the lack of use from the author and devs, npm decided to hand it over when the original author didn’t answer my emails. Let’s see how to do it.

A package has a name

First of all we have to identify a package name that we might want to use. My rule of thumb is to try to find a package that follows most of these:

I find this info with url hacking writing https://npmjs.com/package/NAME for precise matching, but the search functionality has been improved greatly in the recent years so you can use that as well.

There was something weird going on in the early npm versions so the name is case-sensitive; you’ll have to check the lowercase name as that’s the only supported ones nowadays.

Get the package

Great! You found an amazing package name that follows most of the points mentioned above. The quoted dispute policy is to automatically remove a package, but we might also want to use a name that is not in direct violation of the conditions. It’s time to wear our peopleware hat.

It’s simple and well explained: email the person holding the current package. Most people are actually easy to reason with so just ask nicely and give a valid reason (the name is perfect a package you are finishing). CC npm staff so in any way it will be resolved within 1–2 months.

The other person might not have access to that email or not care anymore, in which case npm will intervene and give their verdict about what will happen after few weeks.

Next steps

You might be asked by npm to publish from the 1.x version to avoid any possible compatibility issue. However you can get around this to not yet launch an official build by using 1.0.0-alpha.1 versions first.

Let me know if you get a great name or have any question! Also check out server.js to make a full Node.js server easily with npm install server and:

// index.js

// Include it and extract some methods for convenience
const server = require('server');
const { get, post } = server.router;

// Launch server with some options and a couple of routes
server({ port: 8080 },
  get('/', () => 'Hello world'),
  post('/', ctx => console.log(ctx.data))
);

Originally posted on Medium.