Nur Rony
Polyglot Programmer. Blindly love JS. An automation freak who love to cook code in React, Redux, RxJS and serve them using Docker. Married to the most beautiful girl.

How to publish packages to NPM registry

How to publish packages to NPM registry

Today I just published my first package hlsdownloader to npm. It is pretty easy to publish a package to NPM

I am assuming that you have NodeJS installed in your system.

Configure your account

If you haven’t already set your NPM author info, please run the following commands

npm set "Your Name"
npm set ""
npm set ""
npm adduser

Create Package JSON

Now you need to go to your project’s root directory and run the command if you don’t have any package.json answering the questions it asks.

mkdir my-awesome-module && cd $_
npm init

Add your dependencies

If you are not sure about the dependencies of your package you can easily find out installing this

[sudo] npm install -g pakmanager
# this shows you dependencies as you `require`d them
pakmanager deps

Now add your dependencies with appropriate versions like below

   "dependency-package-1": "version",

Publish your package

Now you are ready to publish your module. Just fire this command in your terminal.

npm publish ./

Thats all!!! take care. If you have something to say or ask I am all ears 🙂

WARNING: Once a package is published with a given name and version, that specific name and version combination can never be used again, even if it is removed with npm-unpublish See this issue