This guide will help you publish your library to npm.
Before publishing, ensure you have completed the following:
- README.md - Comprehensive documentation with examples
- package.json - Complete metadata with keywords, author, repository, homepage
- LICENSE - MIT License file
- CHANGELOG.md - Version history and release notes
- .npmignore - Exclude unnecessary files from npm package
- ng-package.json - Configured to include README, LICENSE, and CHANGELOG
Ensure you're using Node.js v20.19+ or v22.12+:
node --versionIf you need to update Node.js, use nvm:
# Install nvm (if not already installed)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
# Install and use Node.js 20
nvm install 20
nvm use 20Build the production version of your library:
npm run build:prodThis will create the distributable files in dist/ngx-smart-tooltip/.
Check the contents of the dist folder:
cd dist/ngx-smart-tooltip
ls -laYou should see:
README.md- Your library documentationLICENSE- MIT LicenseCHANGELOG.md- Version historypackage.json- Package metadatafesm2022/- ES modulestypes/- TypeScript definitions
Before publishing, test the package locally:
# Create a tarball
npm pack
# This creates ngx-smart-tooltip-1.0.0.tgz
# You can install this in a test project:
# npm install /path/to/ngx-smart-tooltip-1.0.0.tgzIf you haven't already, create an npm account at npmjs.com.
Then login via CLI:
npm loginEnter your:
- Username
- Password
- One-time password (if 2FA is enabled)
From the workspace root, run:
npm run publish:npmOr manually:
# Build first
npm run build:prod
# Navigate to dist folder
cd dist/ngx-smart-tooltip
# Publish
npm publishFor first-time publishing a scoped package, you may need to make it public:
npm publish --access publicAfter publishing, verify your package:
- Visit:
https://www.npmjs.com/package/ngx-smart-tooltip - Check that all metadata is correct
- Verify README displays properly
- Test installation in a new project:
npm install ngx-smart-tooltipWhen publishing updates:
Use semantic versioning:
# Patch release (1.0.0 -> 1.0.1) - Bug fixes
npm version patch
# Minor release (1.0.0 -> 1.1.0) - New features, backward compatible
npm version minor
# Major release (1.0.0 -> 2.0.0) - Breaking changes
npm version majorThis will automatically:
- Update
package.jsonversion - Create a git commit
- Create a git tag
Document your changes in CHANGELOG.md following the existing format.
git add .
git commit -m "chore: release v1.0.1"
git push origin main --tagsnpm run publish:npmAfter successful publication:
- Go to:
https://github.com/techasif/ngx-smart-tooltip/releases/new - Select the version tag (e.g.,
v1.0.0) - Title:
v1.0.0 - Initial Release - Description: Copy from CHANGELOG.md
- Publish release
Ensure your demo site is up to date:
Share your library:
- Twitter/X with hashtags: #Angular #TypeScript #OpenSource
- Reddit: r/angular, r/typescript
- Dev.to article
- Angular Discord/Slack communities
Your README already includes badges that will automatically update:
- npm version
- npm downloads
- bundle size
- license
Make sure you're logged in to the correct npm account:
npm whoamiThe package name ngx-smart-tooltip must be unique. If taken, you'll need to:
- Choose a different name, or
- Use a scoped package:
@yourusername/ngx-smart-tooltip
You cannot republish the same version. Increment the version:
npm version patchEnsure you're using the correct Node.js version (20.19+ or 22.12+):
node --version- Always test locally before publishing
- Use semantic versioning correctly
- Keep CHANGELOG.md updated with every release
- Write meaningful commit messages
- Tag releases in git
- Create GitHub releases for major versions
- Respond to issues and PRs promptly
- Keep dependencies updated
- Monitor bundle size - keep it small!
- Gather feedback from users
Track your library's success:
- npm downloads: npmjs.com/package/ngx-smart-tooltip
- GitHub stars: github.com/techasif/ngx-smart-tooltip
- Issues/PRs: Community engagement
- Bundle size: Keep it under 10kb
- TypeScript support: Maintain type definitions
Your library is now professionally configured and ready for npm publication. Good luck! 🚀
Need Help?
- NPM Documentation: docs.npmjs.com
- Angular Library Guide: angular.dev/tools/libraries
- Semantic Versioning: semver.org