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 🤓

This article was first originally written at: https://www.dassiorleando.xyz/how-i-published-my-first-npm-package-in-1h

The YouTube Channels in both English (En) and French (Fr) are now accessible, Feel free to subscribe by clicking here.

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 more than 1500 according to npm-stat:

NPM Package Download Stats

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.

Resourcehttps://docs.npmjs.com/creating-node-js-modules

———————

We have just started our journey to build a network of professionals to grow our free knowledge-sharing community that will allow you to learn exciting things about topics like cloud computing, software development, and software architectures while keeping the door open to more opportunities.

Does this speak to you? If YES, feel free to Join our Discord Server to stay in touch with the community and be part of independently organized events.

———————

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 this article. Like, recommend, and share if you enjoyed it. Follow us on FacebookTwitter, and LinkedIn for more content.

author-avatar

About Orleando Dassi

I'm a Solutions Architect with 10 years of experience who is constantly learning while impacting the community by producing technical articles/videos, building projects, and conducting tech mentoring/coaching sessions. What describes me the most is my flexibility. Follow me on Twitter and LinkedIn.