Intro

Open source has been a game-changer for us all, it’s even crucial for software developers. I mean none between us can say he never used open-sourced things.

Sometimes we feel like we can add our piece to the puzzle but for some reasons we don’t, I’ve been doing little open source since the start of my career but today I wanted to create my own NPM package … if you read this article maybe you want to follow that route too.

Let me tell you it’s easy to create an NPM package, but not easy to create a helpful package, the one that will be used by at least a thousand of professionals around the globe.

I would advise you not to stay with the focus of creating something no matter what, but rather converting problems you solve daily in packages others can use without spending hours solving the same things.

We all know how lazy we Software developers are, I’m not an exception then I’ll use your useful package too 🤓

My First Package

Basically I created my first NPM package, it had 30 installations during the first day, 70 installations 48 hours after its inception, 108 downloads three days later and now it’s npm

Quite motivating to do more, not only because it’s used by other developers but primarily because I really depend on open source myself.

It’s called paykickstart-ipn-validator, its only and unique purpose is to validate incoming IPN notifications got from PayKickStart.

To better the funnel of your App sold via a third-party service you often need to do further actions once payment/refund/subscribe/unsubscribe operations are made via your sales/dashboard/landing pages, doing this without confirming the validity of the notification will fail your workflow as not only the intended party can send requests to your server (IPN receiver/controller).

You can install it just by hitting this:

$ npm install paykickstart-ipn-validator --save

It’s open-source, you can grab it over on GitHub.

Publishing Steps

Here are the steps I used to have my package up and running in no more than 1 hour assuming you have your code built already in your machine.

  1. Create a git repo for your package if it’s open-source, let’s not that private NPM packages can be published too
  2. Sign up at npmjs.com
  3. There are some required and/or important things to do into your repo so that it looks professional as the other you used to pay attention to. I would advise using this template to have all these metadata defined, you then need to update with your own details
  4. Setting up a Travis build so that it triggers your test anytime you commit/merge on the master branch, it’s good to have the build status of your package anytime so that we’ll feel safe using a particular working version  (any Travis alternative will do)
  5. From your package root folder in the command line, hit npm login to sign in using your NPM account then npm publish to send all to the NPM registry, yep it’s done 😉

Note: To better understand the structure of the package.json file you can read the official guide.

Resource: https://docs.npmjs.com/creating-node-js-modules

Conclusion

In this short tutorial, we highlighted the basic steps needed in order to publish an NPM package to the NPM registry, no magic, no extra thing, straight to the point and I hope it’s easy to follow by all developers regardless of their level to do the same.

Thanks for reading


Dassi Orleando

Full-Stack developer by formation and profession, fixer, driver, entrepreneur, freelancer and passionate about all around IT, I love implement or use different things all the days. If you would like to contact or follow me, you can do so below.

Related Posts

AngularJS

Build a real time app with MEAN2 and socket.io

Build a simple real-time application that you can use as a starter to do what you want with MEAN2(MongoDB, Express, Angular2 & NodeJS), within the project will also be Socket.io, Typescript and Angular-material2. After having worked with Angular2 Read more...

AngularJS

AngularJs’s global objects instead of native ?

AngularJs is one of the widely used open sources front-end framework because of its good architecture in place, the extensibility, a lot of interesting features and the big community too. In this short article, we're going Read more...

Shares