Introduction
In this article I am going to share with you the simplest way to create your own NPM package and Publish it to npmjs.com. Before that, if you are new to Node keyword or Node.js , you can follow some introductory stuff from below links :
In this article I am going to share with you the simplest way to create your own NPM package and Publish it to npmjs.com. Before that, if you are new to Node keyword or Node.js , you can follow some introductory stuff from below links :
Steps to create and initialize project with VS CODE
Step 1
Create new project in Visual Studio code

Here I have created an empty project named helloworldtest , and open it using VS CODE IDE
Step 2 - Create package.json file
Because at first glance we dont have anything , so we should create package.json file by executing following command
Step 1
Create new project in Visual Studio code

Here I have created an empty project named helloworldtest , and open it using VS CODE IDE
Step 2 - Create package.json file
Because at first glance we dont have anything , so we should create package.json file by executing following command
- npm init
By executing above command , there are some questions you should answer it as follows,

After entering command npm init , you can see that they ask you about name of project, but keep in mind that name should be small latters and can not contain digits
Step-3
Then the next step to specify version

I have given 1.0.0 but you can give version as appropriate for your package release
Step-4
Than provide description about package and entry point of your package when project is loaded

As you can see in the above screenshot, I have provided a simple description that would publish when someone goes through your package
Step-5
Some more steps like Providing git repository , keywords and Author name to identify the creator of current package

I have entered some details like helloworldtest [which is unique by the way] and test command
NOTE
I have not provided git repository , but if you already have created empty repository you can specify its URL
Step-6
Last step is a summary , in which you can see all the information provided by you

That's it , we have created package.json file with all the needed information
NOTE
Before we publish package we should have account created with npmjs.com site , so that we can publish it by login credential .
Steps to create user and login through VS CODE
Step 1
Firstly we need to add user by using following command

After entering command npm init , you can see that they ask you about name of project, but keep in mind that name should be small latters and can not contain digits
Step-3
Then the next step to specify version
I have given 1.0.0 but you can give version as appropriate for your package release
Step-4
Than provide description about package and entry point of your package when project is loaded

As you can see in the above screenshot, I have provided a simple description that would publish when someone goes through your package
Step-5
Some more steps like Providing git repository , keywords and Author name to identify the creator of current package

I have entered some details like helloworldtest [which is unique by the way] and test command
NOTE
I have not provided git repository , but if you already have created empty repository you can specify its URL
Step-6
Last step is a summary , in which you can see all the information provided by you

That's it , we have created package.json file with all the needed information
NOTE
Before we publish package we should have account created with npmjs.com site , so that we can publish it by login credential .
Steps to create user and login through VS CODE
Step 1
Firstly we need to add user by using following command




Sumit ChaudharyPosted Mar 1, 2018, 11:21 AM
Good one this and also explained.
Bikash SahuPosted Feb 26, 2018, 10:45 PM
Well explained and nice article.
Hemal JoshiPosted Jan 8, 2018, 7:51 AM
Good Going Brother
Manav PandyaPosted Dec 31, 2017, 2:59 AM
Glad you like it sir Dharmraj Thakur ..............
Dharmraj ThakurPosted Dec 31, 2017, 2:53 AM
Nice content and explaination...
Manav PandyaPosted Dec 30, 2017, 1:03 AM
Thanks Sir Hiten Pandya ...............
Hiten PandyaPosted Dec 30, 2017, 12:47 AM
Good one..Thanks for sharing....
Manav PandyaPosted Dec 30, 2017, 12:17 AM
Thanks for ur comment sir Bhavesh Jadav ........
Bhavesh JadavPosted Dec 29, 2017, 11:44 PM
Thank Manav, helpful article...
Manav PandyaPosted Dec 29, 2017, 11:10 PM
Thanks for ur comment sir Naresh Singhal ...........
Naresh SinghalPosted Dec 29, 2017, 11:09 PM
Very Nice Article Manav, Explained well in deep , Keep it on ....
Manav PandyaPosted Dec 29, 2017, 11:08 PM
Glad you like it Ahsan Siddique ...........
Ahsan SiddiquePosted Dec 29, 2017, 1:42 PM
Nice friend....keep it up