Introduction

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

Sometimes we feel like we can add our piece to the puzzle but for some reason, 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 something, it’s easy to create an NPM package, but not easy to create a helpful package, the one that will be used by hundreds of professionals around the globe.

I would advise you not to stay focused on creating something no matter what, but rather convert problems you solve daily into 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, so I’ll use your useful package too 🤓

My First Package

Basically, I created my first NPM package, it had 30 installations on 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 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 on your computer.

  1. Create a git repo for your package if it’s open-source, let’s note that private NPM packages can be published too
  2. Sign up at npmjs.com
  3. There are some required and important things to do in your repo to look as professional as the others you used to pay attention to. I would advise using this template to have all this metadata defined, you then need to update with your details.
  4. [Optional] 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 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!


Orleando Dassi

I'm a Solutions Architect who is constantly learning to better himself while impacting the community by producing technical articles and videos, what describes me the most is my flexibility.

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...

Angular

Custom State Management Architecture using RxJS

As a developer, building frontend applications is becoming less difficult using a set of techniques that have been standardized with time, within that jargon, one of these is the State Management System which is a 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