1. npm-name
Check whether a package or organization name is available on npm
npm-name
Package: npm-name
Created by: sindresorhus
Last modified: Sat, 10 Feb 2024 18:55:15 GMT
Version: 8.0.0
License: MIT
Downloads: 489,437
Repository: https://github.com/sindresorhus/npm-name

Install

npm install npm-name
yarn add npm-name

npm-name

Check whether a package or organization name is available on npm

Install

 npm install npm-name

Usage

 import npmName from 'npm-name';

// Check a package name
console.log(await npmName('chalk'));
//=> false

// Check an organization name
console.log(await npmName('@ava'));
//=> false

console.log(await npmName('@abc123'));
//=> true

try {
	await npmName('_ABC');
} catch (error) {
	console.log(error.message);
	// Invalid package name: _ABC
	// - name cannot start with an underscore
	// - name can no longer contain capital letters
}

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

The name to check.

options

Type: object

registryUrl

Default: User's configured npm registry URL.

THe 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.

npmNameMany(names, options?)

Check whether multiple package/organization names are available (not registered) on npm.

Returns a Promise<Map> of name and status.

 import {npmNameMany} from 'npm-name';

const result = await npmNameMany(['chalk', '@sindresorhus/is', 'abc123']);

console.log(result.get('chalk'));
//=> false

console.log(result.get('@sindresorhus/is'));
//=> false

console.log(result.get('abc123'));
//=> true

names

Type: string[]

Multiple names to check.

options

Type: object

Same as npmName().

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code