What is npm-name?
The npm-name package is used to check the availability of package names on the npm registry. It helps developers to determine if a particular package name is already taken or if it is available for use.
What are npm-name's main functionalities?
Check single package name
This feature allows you to check if a single package name is available on the npm registry. The code sample demonstrates how to use the npm-name package to check the availability of 'some-package-name'.
const npmName = require('npm-name');
(async () => {
const isAvailable = await npmName('some-package-name');
console.log(isAvailable ? 'Available' : 'Taken');
})();
Check multiple package names
This feature allows you to check the availability of multiple package names at once. The code sample shows how to check the availability of 'package-one' and 'package-two' using the npm-name package.
const npmName = require('npm-name');
(async () => {
const result = await npmName.many(['package-one', 'package-two']);
console.log(result);
})();
Check scoped package name
This feature allows you to check the availability of a scoped package name. The code sample demonstrates how to check if '@scope/some-package-name' is available on the npm registry.
const npmName = require('npm-name');
(async () => {
const isAvailable = await npmName('@scope/some-package-name');
console.log(isAvailable ? 'Available' : 'Taken');
})();
Other packages similar to npm-name
npm-name-cli
The npm-name-cli package is a command-line interface tool for checking the availability of npm package names. While npm-name is a library that can be integrated into other Node.js applications, npm-name-cli is specifically designed for use in the terminal, making it a good choice for developers who prefer command-line tools.
npm-name
Check whether a package or organization name is available on npm
Install
$ npm install npm-name
Usage
const npmName = require('npm-name');
(async () => {
console.log(await npmName('chalk'));
console.log(await npmName('@ava'));
console.log(await npmName('@abc123'));
const result = await npmName.many(['chalk', '@sindresorhus/is', 'abc123']);
console.log(result.get('chalk'));
console.log(result.get('@sindresorhus/is'));
console.log(result.get('abc123'));
try {
await npmName('_ABC');
} catch (error) {
console.log(error.message);
}
})();
API
npmName(name, options?)
Check whether a package/organization name is available (not registered) on npm.
An organization name should start with @
and should not be a scoped package.
Returns a Promise<boolean>
of whether the given name is available.
name
Type: string
Name to check.
options
Type: object
registryUrl
Default: User's configured npm registry URL.
Registry URL to check name availability against.
Note: You're unlikely to need this option. Most use-cases are best solved by using the default. You should only use this option if you need to check a package name against a specific registry.
npmName.many(names, options?)
Check whether multiple package/organization names are available (not registered) on npm.
Returns a Promise<Map>
of name and status.
names
Type: string[]
Multiple names to check.
options
Type: object
Same as npmName()
.
Related