# Publishing to NPM This document provides step-by-step instructions for publishing the IMG2MP3 package to NPM. ## Prerequisites 1. **NPM Account**: Ensure you have an NPM account at [npmjs.com](https://www.npmjs.com/) 2. **NPM CLI**: Make sure npm is installed and up to date 3. **Authentication**: You need to be logged in to npm ## Pre-publication Steps ### 1. Verify Package Information Check that all package information is correct: ```bash # Review package.json cat package.json # Check package structure npm pack --dry-run ``` ### 2. Test the Package Locally ```bash # Install dependencies npm install # Test CLI commands node bin/cli.js --help node bin/cli.js info --help # Test the API node examples/basic_usage.js ``` ### 3. Check for Available Package Name ```bash # Check if package name is available npm view img2mp3 # If the package exists, you'll need to choose a different name # Consider variations like: img2mp3-steganography, img-to-mp3, etc. ``` ### 4. Verify Package Contents ```bash # See what files will be included in the package npm pack --dry-run # The output should include: # - src/ # - bin/ # - examples/ # - index.d.ts # - README.md # - LICENSE # - package.json ``` ## Publishing Steps ### 1. Login to NPM ```bash npm login ``` Enter your NPM credentials when prompted. ### 2. Verify Login ```bash npm whoami ``` This should display your NPM username. ### 3. Publish the Package For first-time publication: ```bash npm publish ``` If the package name is already taken, you can: - Choose a scoped package name: `npm publish --access public` - Or update the name in package.json and try again ### 4. Verify Publication After successful publication: ```bash # Check the package on NPM npm view img2mp3 # Test installation npm install -g img2mp3 # Test global installation img2mp3 --help ``` ## Post-publication Steps ### 1. Create Git Repository If you haven't already: ```bash git init git add . git commit -m "Initial release v1.0.0" git tag v1.0.0 # Add remote and push (update URL with your repo) git remote add origin https://github.com/ale/img2mp3.git git push -u origin main git push --tags ``` ### 2. Update Repository Links Ensure the repository URLs in package.json point to your actual repository. ### 3. Documentation - Update the README.md with the correct installation instructions - Add any platform-specific installation notes - Include examples and screenshots if possible ## Updating the Package For future updates: ### 1. Update Version ```bash # For patch updates (bug fixes) npm version patch # For minor updates (new features) npm version minor # For major updates (breaking changes) npm version major ``` ### 2. Update Changelog Update CHANGELOG.md with the new changes. ### 3. Publish Update ```bash npm publish ``` ### 4. Tag the Release ```bash git push --tags ``` ## Package Name Alternatives If "img2mp3" is already taken, consider these alternatives: - `img2mp3-encoder` - `image-to-mp3` - `mp3-steganography` - `img2audio` - `steganography-mp3` - `audio-image-encoder` - `img-audio-hide` - `@yourname/img2mp3` (scoped package) ## Troubleshooting ### Package Name Already Exists ```bash # Option 1: Use a scoped package # Update package.json name to "@yourusername/img2mp3" npm publish --access public # Option 2: Choose a different name # Update package.json name field and try again ``` ### Authentication Issues ```bash # Clear NPM cache npm cache clean --force # Re-login npm logout npm login ``` ### Permission Errors ```bash # Check if you're added to the package as collaborator npm owner ls img2mp3 # Add yourself if needed (package owner must do this) npm owner add yourusername img2mp3 ``` ## Success Verification After successful publication, your package should be: 1. **Searchable**: Available at https://www.npmjs.com/package/img2mp3 2. **Installable**: `npm install -g img2mp3` works 3. **Executable**: `img2mp3 --help` shows help text 4. **Functional**: Basic encode/decode operations work ## Marketing Your Package 1. **GitHub README**: Ensure your GitHub repository has a comprehensive README 2. **Keywords**: Good keywords in package.json help discoverability 3. **Documentation**: Complete API documentation and examples 4. **Social Media**: Share your package on relevant communities 5. **Blog Post**: Write about the technical implementation and use cases Remember to respect copyright laws and include appropriate disclaimers about the intended use of steganography tools.