This guide walks you through publishing the @numsy package to NPM using pnpm.
If you donβt have pnpm installed:
# Using npm
npm install -g pnpm
# Using Node.js Corepack (recommended)
corepack enable
corepack prepare pnpm@latest --activate
# Verify installation
pnpm --version
If you donβt have an NPM account:
pnpm login
# or
npm login
Enter your:
Edit package.json:
{
"name": "@numsy", // Or "@your-username/number-processor"
"version": "1.0.0",
"author": "Your Name <your.email@example.com>",
"repository": {
"type": "git",
"url": "https://github.com/your-username/number-processor.git"
}
}
Important: Change the package name if needed:
@your-username/number-processor or @your-org/number-processornumber-processor-indian (must be unique on NPM)cd Number-Processor
pnpm install
This will create pnpm-lock.yaml which should be committed to git.
# Lint the code
pnpm run lint
# Run tests
pnpm test
# Check test coverage
pnpm run test:cov
pnpm run build
This creates the dist/ directory with compiled JavaScript files.
Test your package locally before publishing:
# Pack the package (creates a .tgz file)
pnpm pack
# This creates: numsy-1.0.0.tgz
You can test install it in another project:
cd /path/to/test-project
pnpm add /path/to/numsy-1.0.0.tgz
Check what will be published:
# List files that will be included
pnpm pack --dry-run
Make sure only necessary files are included (no src/, test/, etc.).
pnpm publish --access public
pnpm publish
https://www.npmjs.com/package/@numsypnpm add @numsy
Follow Semantic Versioning:
# Patch update (1.0.0 -> 1.0.1)
pnpm version patch
# Minor update (1.0.0 -> 1.1.0)
pnpm version minor
# Major update (1.0.0 -> 2.0.0)
pnpm version major
# Then publish
pnpm publish --access public
The version script will automatically:
Then the postversion script will:
{
"name": "@numsy", // Package name on NPM
"version": "1.0.0", // Current version
"description": "...", // Shows on NPM
"main": "dist/main.js", // Entry point for require()
"types": "dist/main.d.ts", // TypeScript definitions
"files": [ // Files to include in package
"dist",
"public",
"README.md",
"LICENSE"
],
"keywords": [...], // Searchable on NPM
"author": "Your Name", // Your name
"license": "MIT", // License type
"repository": {...}, // GitHub repo
"engines": { // Node/pnpm requirements
"node": ">=16.0.0",
"pnpm": ">=8.0.0"
},
"packageManager": "pnpm@8.15.0" // Enforces pnpm usage
}
# Using pnpm
pnpm add @numsy
# Using npm
npm install @numsy
# Using yarn
yarn add @numsy
import { PhoneValidatorService } from '@numsy';
const validator = new PhoneValidatorService();
const result = validator.validateAndSanitize('98765-43210');
console.log(result);
// {
// original: '98765-43210',
// sanitized: '9876543210',
// isValid: true
// }
Before publishing, make sure:
pnpm test)pnpm run lint)pnpm run build)pnpm login)git tag v1.0.0
git push origin v1.0.0
Create CHANGELOG.md:
# Changelog
## [1.0.0] - 2026-03-06
### Added
- Initial release
- Phone number validation for Indian numbers
- CSV and Excel file parsing
- Drag-and-drop web interface
After publishing to NPM, create a GitHub release with:
Set up GitHub Actions for automated publishing:
# .github/workflows/publish.yml
name: Publish to NPM
on:
release:
types: [created]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/setup-node@v3
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
- run: pnpm install
- run: pnpm test
- run: pnpm run build
- run: pnpm publish --access public
env:
NODE_AUTH_TOKEN: $
Solution: Use a scoped package name:
"name": "@your-username/number-processor"
Error: npm ERR! need auth This command requires you to be logged in.
Solution:
pnpm login
If you have 2FA enabled on NPM:
pnpm publish --otp=123456
Replace 123456 with your 2FA code.
Error: 402 Payment Required
Solution: Either:
pnpm publish --access publicCheck .npmignore and files field in package.json.
# See what will be published
pnpm pack --dry-run
https://npmjs.com/package/@numsyhttps://unpkg.com/@numsyhttps://bundlephobia.com/Add NPM badge to README:
[](https://www.npmjs.com/package/numsy)
You can unpublish within 72 hours:
# Unpublish specific version
pnpm unpublish @numsy@1.0.0
# Unpublish entire package (dangerous!)
pnpm unpublish @numsy --force
Warning: Unpublishing can break projects that depend on your package!
# Install dependencies
pnpm install
# Build
pnpm run build
# Test
pnpm test
# Lint
pnpm run lint
# Create package
pnpm pack
# Publish
pnpm publish --access public
# Update version
pnpm version patch|minor|major
# Login
pnpm login
# Check who you're logged in as
pnpm whoami
If you encounter issues:
Ready to publish? Run these commands:
cd Number-Processor
pnpm install
pnpm run lint
pnpm test
pnpm run build
pnpm publish --access public
Good luck! π