Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
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.
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');
})();
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.
Check whether a package name is available on npm
$ npm install npm-name
const npmName = require('npm-name');
(async () => {
console.log(await npmName('chalk'));
// false
const result = await npmName.many(['chalk', '@sindresorhus/is', 'abc123'])
console.log(result.get('chalk'));
//=> false
console.log(result.get('@sindresorhus/is'));
//=> false
console.log(result.get('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
}
})();
Returns a promise for a boolean.
Type: String
Name to check.
Returns a promise for a Map
of name/status.
Type: Array
Multiple names to check.
MIT © Sindre Sorhus
FAQs
Check whether a package or organization name is available on npm
The npm package npm-name receives a total of 163,531 weekly downloads. As such, npm-name popularity was classified as popular.
We found that npm-name demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.