Publish Node package on NPM

NPM registry is the best place to share your node package globally. NPM is powered by a couchDB database. We will go through the process of creating the node package and publishing it as a public package.

  1. First you have to create a free account on

2. Login the npm cli using your username and credentials.

On the command line -

npm login
Username: <your-username>
Email: (this IS public) <youremail>@<>

If the above information is correct you will get the message as:

Logged in as <username> on

3. Now we have to create a node package, you need a directory to hold your code and initiate the package creation.

On the command line -

mkdir mynodepackage

cd mynodepackage

Now we are in the directory of our project, here we will initiate the npm package using command :

npm init <mynodepackage>

package name: (mynodepackage) mynodepackage
version: (1.0.0)
entry point: (index.js)
test command:
git repository:
author: asad.iqbal
license: (ISC) MIT
About to write to C:\mynodepackage\package.json:

“name”: “mynodepackage”,
“version”: “1.0.0”,
“description”: “”,
“main”: “index.js”,
“scripts”: {
“test”: “echo \”Error: no test specified\” && exit 1"
“author”: “asad.iqbal”,
“license”: “MIT”

4. Great you have your package ready to publish, though it is an empty package, if you want to export modules then add them in index.js which is the entry point of the package.

5. Lets publish it on npm now

On command line:

npm publish — access public

If the name of your package is not unique accross whole registry then you will get the following error -

403 Forbidden — PUT — You do not have permission to publish “qdb”. Are you logged in as the correct user?

In this case you can append some text with your package name to make it unique and try publishing again.

Great your NPM package is now published, and you know so many developers had been waiting to install your package and use your awsome code!!!.

They just need to write

npm install <your-package-name>

WALLA !!!!




Software architect

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Can I use Three.js with React?

Dynamic component creation in Vue.js

Java Optional as a Stream

Stream of water

Mr Frontend weekly link sharing #51

How to use clash-of-clans-api

Accessibility 360 — Web 🕸 and mobile📱

Understanding Deep and Shallow Copy in Javascript.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Asad Iqbal

Asad Iqbal

Software architect

More from Medium

ICYMI: ProjectOasis X Mogul Productions


Polygon x Defina AMA Recap

DTG Wizard Watch