- You must have Node.js and NPM installed and configured properly.
- You must have basic understanding to handle terminal/command prompt.
- You must have your module initialized and configure properly (It’s Simply means you have your package.json created (using
npm init) and it has valid information about your module that can be used by NPM itself).
- You must have account at npmjs.com
- You must have account at github.com or bitbucket.org or any similar site where you have an online repository of your module.
- You must have already pushed your module latest source code to the online repository.
Follow following steps to publish your module to NPM (npmjs.com):
Step 1: Open Terminal or Command Prompt and Navigate to your Module directory.
Step 2: If you haven’t already set your NPM author information the follow this step else proceed to next step:
Type following command(s) to set required author information:
npm set init.author.name "Your Name"
npm set init.author.email "email@example.com"
npm set init.author.url "http://yoursite.com"
Step 3: Add user to NPM (Login with your NPM Account):
Type following command(s) to add NPM user:
This would ask you to enter your Username, Password and Email. Just enter correct information and it would acknowledge you with a success or error message. If you get successfully logged In, proceed to next step else resolve the error/issue and then proceed to next step.
Step 4: Publish your Module using following command:
Step 5: Verify your published Module:
You can verify that by simply login to your account at npmjs.com
Try to install your published module in any of your node application by simply using following command:
Final Step: Cheers!
Bhanu PS (psbhanu) is professionally a software engineer and loves helping people plan, develop, and launch applications.
He has spent the majority of his career in the application development industry, gaining experiences in areas such as web, network, mobile and game application development.
While managing and developing applications is his primary job function by day, psbhanu also love to write poems, blogs, tutorials, research and articles.
He also enjoys spending time with his family and loved ones.