Contributing packages to npm

If you are a open source developer then you may feel to contribute to open source as well. This post helps you to get started with contributing to open source especially npm (Since I am a javascript lover).

Prerequisites:

  • Install node
  • Install npm

Creating the package:

  • Create a directory

$ mkdir <your project name>

  • Create a npm project

$ cd <your project name>
$ npm init

  • Give details as required.
  • Create your project files
    $ vi somefile.js
  • In your file start writing your functions
    yourFunction = function () { .... };
  • Dont forget to export your function at the end of the file.
    exports.default = yourFunction

Publishing:

  • Once your package is ready then you need to publish it to npm
  • To publish to npm you first need an account in npm
  • Then add your account to your machine

$ npm adduser

  • Give your username and password.
  • Now, ready to publish

$ npm publish

Yay!! your package is published and you are a open source contributor.

Javascript rocks!!!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s