Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I check if a NPM package name is available?

Tags:

npm

I used to check if a package name is available by opening https://www.npmjs.com/package/<name>.

That doesn’t work anymore as NPM checks for similar-name conflicts.

Is there a different way?

like image 558
sunknudsen Avatar asked Sep 18 '19 19:09

sunknudsen


2 Answers

  1. npm-name

npm-name @ npm / npm-name @ GitHub

Check whether a package or organization name is available on npm

Install:

$ npm install npm-name

Usage:

const npmName = require('npm-name');
 
(async () => {
    // Check a package name
    console.log(await npmName('chalk'));
    //=> false
 
 
    // Check an organization name
    console.log(await npmName('@ava'));
    //=> false 
})();
  1. npm-name-cli

npm-name-cli @ npm / npm-name-cli @ GitHub

Install:

$ npm install --global npm-name-cli

Usage:

$ npm-name --help

  Usage
    $ npm-name <name> …

  Examples
    $ npm-name chalk
    ✖ chalk is unavailable
    $ npm-name abc123
    ⚠ abc123 is squatted
    $ npm-name unicorn-cake
    ✔ unicorn-cake is available
    $ npm-name @ava
    ✖ @ava is unavailable
    $ npm-name @abc123
    ✔ @abc123 is available
    $ npm-name @sindresorhus/is unicorn-cake
    ✖ @sindresorhus/is is unavailable
    ✔ unicorn-cake is available

  Exits with code 0 when all names are available or 2 when any names are taken
like image 138
zerocewl Avatar answered Sep 30 '22 20:09

zerocewl


If you are interested in checking if an organization name is free, use the following URL:

https://npmjs.com/org/ORG_NAME_HERE

If you're getting a "404 Not Found" error, it means the name is free. Otherwise it is not.

like image 30
Paul Razvan Berg Avatar answered Sep 30 '22 21:09

Paul Razvan Berg