can-i-publish
v0.0.5
Published
Check if your npm package name is actually publishable. Tests against npm's undocumented similarity filter.
Maintainers
Readme
The Problem
You check if a package name is available on npm. It says yes. You build the whole thing. You run npm publish. Boom:
403 Package name too similar to existing packages degit,pdfkit,exitnpm has an undocumented similarity filter that blocks names even if they don't exist on the registry. npm publish --dry-run doesn't catch it either. Neither does npm-name-cli.
can-i-publish actually tests publishability by checking both the registry AND the similarity filter.
npm-name-cli vs can-i-publish
Try it yourself — check dxkit, a name that looks available but is actually blocked:
# npm-name-cli says it's available (wrong — will fail on npm publish)
$ npx npm-name-cli dxkit
✔ dxkit is available
# can-i-publish catches the similarity block
$ npx can-i-publish dxkit
⚠ dxkit is blocked by npm similarity filter
Similar to: degit, pdfkit, exitOther names you can verify: reacto, expresss, loadash, chulk.
| | npm-name-cli | can-i-publish |
|---|---|---|
| Registry check | Yes | Yes |
| Organization check (@org) | Yes | Yes |
| Squatter detection | Yes | Yes |
| Similarity filter | No | Yes |
| Catches dxkit as blocked | No | Yes |
| Shows similar packages | No | Yes |
| Suggests alternatives | No | Yes (--suggest) |
Install
npx can-i-publish my-packageOr install globally:
npm install -g can-i-publishUsage
# Check a single name
can-i-publish my-package
# Check multiple names at once
can-i-publish my-tool my-lib my-app
# Check an organization name
can-i-publish @my-org
# Get suggestions if blocked
can-i-publish dxkit --suggest
# JSON output (for scripting)
can-i-publish my-package --jsonOutput
$ can-i-publish abc123 chalk dxkit my-cool-tool @ava
⚠ abc123 is squatted (https://www.npmjs.com/package/abc123)
✖ chalk is unavailable (https://www.npmjs.com/package/chalk)
⚠ dxkit is blocked by npm similarity filter
Similar to: degit, pdfkit, exit
✔ my-cool-tool is available
✖ @ava is unavailable (https://www.npmjs.com/org/ava)How It Works
- Validates the name against npm naming rules (lowercase, no spaces, under 214 chars)
- Checks the registry to see if the package already exists
- Detects squatters — flags packages that exist but appear abandoned (low downloads, no readme, no prod version)
- Tests the similarity filter by attempting a publish probe against the npm registry using your npm credentials
[!NOTE] Step 4 requires npm credentials. Run
npm loginfirst, or setNPM_TOKENas an environment variable. If you're not logged in,can-i-publishwill still check steps 1-3 and let you know that similarity wasn't tested.
Options
| Flag | Description |
|------|-------------|
| -s, --suggest | Suggest alternative names if unavailable |
| -j, --json | Output results as JSON |
| -V, --version | Show version |
| -h, --help | Show help |
Exit Codes
0— all names are available or squatted1— one or more names are unavailable, blocked, or invalid
Useful for CI/scripting:
can-i-publish my-package && npm publishProgrammatic API
import { checkName, suggestNames } from 'can-i-publish';
const result = await checkName({ name: 'my-package' });
// { name, status: 'available' | 'taken' | 'squatted' | 'blocked' | 'invalid', reason?, similarTo? }
const suggestions = await suggestNames({ name: 'dxkit', limit: 5 });
// [{ name: 'dxkit-cli', status: 'available' }, ...]Credits
Inspired by npm-name-cli by Sindre Sorhus.
License
MIT
Built with commandcode by @saqibameen
