Follow these steps to publish your CLI to npm:
- Go to https://www.npmjs.com/signup
- Create a free account
- Verify your email
npm loginEnter your:
- Username
- Password
- One-time password (if 2FA is enabled)
npm whoamiThe package name is: createx
Check if it's available:
npm search createxOr check on: https://www.npmjs.com/package/createx
✅ Good news: createx is available and ready to use!
Test your CLI works before publishing:
# Install dependencies
npm install
# Test the CLI
node index.js
# Link it globally to test the bin command
npm link
# Test the global command
initgen
# Unlink when done testing
npm unlink -g initgennpm publish --dry-runnpm publish- Check on npm: https://www.npmjs.com/package/createx
- Wait 2-5 minutes for indexing
- Test installation:
# Install globally
npm install -g createx
# Or use npx (no installation needed)
npx createxWhen you make changes and want to publish a new version:
# Patch version (1.0.0 -> 1.0.1) - for bug fixes
npm version patch
# Minor version (1.0.0 -> 1.1.0) - for new features
npm version minor
# Major version (1.0.0 -> 2.0.0) - for breaking changes
npm version majornpm publish --access publicAfter publishing, users can install your CLI:
# Install globally
npm install -g initgen
# Run with npx (no installation)
npx initgen
# Or use the command
initgen-
Scoped Packages: Packages like
@pankajkumardev/...are scoped to your username- Free for public packages
- Require
--access publicflag when publishing
-
Version Numbers: Follow semantic versioning
-
MAJOR.MINOR.PATCH (e.g., 1.0.0)
-
Can't publish the same version twice
-
MAJOR.MINOR.PATCH (e.g., 1.0.0)
-
Can't publish the same version twice
-
-
Package Size: Keep it under 10MB if possible
- Check size:
npm pack --dry-run
- Check size:
-
README: Your README.md will be the package homepage on npm
-
Keywords: Good keywords help users find your package
- Use a scoped package:
@yourusername/package-name - Choose a different unique name
- Check your email and verify your npm account
- Run
npm loginagain
- You're trying to publish a private scoped package
- Add
--access publicflag
- You don't have permission to publish under this name
- The package might be owned by someone else
-
Share on Twitter/LinkedIn
-
Add npm badge to README:
 
-
Track downloads: https://npm-stat.com/charts.html?package=createx
-
Monitor issues on GitHub
-
Keep package updated
# Login
npm login
# Test locally
npm link
# Check what will be published
npm publish --dry-run
# Publish
npm publish
# Update version
npm version patch
# View package info
npm info createx
# Unpublish (within 72 hours)
npm unpublish createx@1.0.0Ready to publish? Run these commands:
npm login
npm publish🎉 That's it! Your CLI will be live on npm!