This guide explains how to publish the @csfloat/ngx-angular-query-builder library to the npm registry.
- npm Account: Create an account at npmjs.com
- npm Access Token: Create an automation token from your npm account settings
- GitHub Repository: Ensure your code is pushed to a GitHub repository
- Organization Access: Ensure you have publish permissions for the
@csfloatorganization on npm
-
Create npm Access Token:
- Go to npmjs.com → Account Settings → Access Tokens
- Click "Generate New Token" → "Automation"
- Copy the token
-
Add token to GitHub Secrets:
- Go to your GitHub repository → Settings → Secrets and variables → Actions
- Click "New repository secret"
- Name:
NPM_TOKEN - Value: Your npm access token
If you want to publish manually:
-
Build the library:
npm run build-package
-
Navigate to the dist folder:
cd dist/ngx-angular-query-builder -
Login to npm:
npm login
- Username: Your npm username
- Password: Your npm password
- Email: Your npm email
- One-time password: If you have 2FA enabled
-
Publish:
npm publish
The project is configured for automated publishing via GitHub Actions.
-
Update version number:
# Update version in projects/ngx-angular-query-builder/package.json # For example, change "19.0.0" to "19.0.1"
-
Create a new release:
- Go to your GitHub repository
- Click "Releases" → "Create a new release"
- Tag version:
v19.0.1(match your package version) - Release title:
Release v19.0.1 - Describe the changes
- Click "Publish release"
-
GitHub Actions will automatically:
- Install dependencies
- Build the library
- Run tests
- Publish to npm
You can also manually trigger the workflow:
- Go to Actions tab in your GitHub repository
- Select "Publish to npm" workflow
- Click "Run workflow"
Before publishing a new version:
-
Update the library package.json:
// projects/ngx-angular-query-builder/package.json { "version": "19.0.1" // Update this }
-
Commit and tag:
git add . git commit -m "Release v19.0.1" git tag v19.0.1 git push origin main --tags
Once published, users can install your package easily:
npm install @csfloat/ngx-angular-query-builderNo authentication required! 🎉
-
Authentication Error:
- Ensure your npm token is valid and has publish permissions
- Check that the NPM_TOKEN secret is correctly set in GitHub
- Verify you have access to publish under the
@csfloatorganization
-
Organization Access:
- You must be a member of the
@csfloatorganization on npm - The organization must exist on npm
- Your npm token must have permission to publish to the organization
- You must be a member of the
-
Version Already Published:
- You cannot publish the same version twice
- Increment the version number in package.json
-
Build Errors:
- Run
npm run build-packagelocally to check for issues - Ensure all dependencies are correctly specified
- Run
# Check what will be published
cd dist/ngx-angular-query-builder
npm pack --dry-run
# View package info
npm view @csfloat/ngx-angular-query-builder
# List published versions
npm view @csfloat/ngx-angular-query-builder versions --json
# Check if organization exists
npm org ls @csfloat- Never commit npm tokens to your repository
- Use GitHub secrets for sensitive information
- Regularly rotate your npm access tokens
- Consider enabling 2FA on your npm account
If the @csfloat organization doesn't exist on npm yet:
-
Create the organization:
- Go to npmjs.com
- Click your profile → "Add Organization"
- Name:
csfloat - Choose organization type (free for public packages)
-
Add team members:
- Invite other CSFloat team members to the organization
- Set appropriate permissions for each member
-
Configure organization settings:
- Set up organization profile and description
- Configure package access policies if needed