Publish your Node.js Module to NPM (npmjs.com)

Prerequisite(s):

  1. You must have Node.js and NPM installed and configured properly.
  2. You must have basic understanding to handle terminal/command prompt.
  3. 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).
  4. You must have account at npmjs.com
  5. You must have account at github.com or bitbucket.org or any similar site where you have an online repository of your module.
  6. 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 "you@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:
npm adduser

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:
npm publish

Step 5: Verify your published Module:
You can verify that by simply login to your account at npmjs.com
or
Try to install your published module in any of your node application by simply using following command:
npm install

Final Step: Cheers!

psbhanu

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.

Leave a Reply

avatar

This site uses Akismet to reduce spam. Learn how your comment data is processed.