Steps for Creating and Publishing a NPM Package

Feature thumb publishing npm packages

Accounts you'll need

NPM Registry GitHub


Tools you'll need installed

Text editor (Visual Studio Code, Atom, Sublime Text, etc) Node (which comes with NPM)



After ensuring that Node is installed, provide your details with the following commands in the terminal:

npm set "Your name"
npm set ""
npm set ""


Run the following command to login to the NPM registry:

npm login


Create a GitHub repo for your package


Create a directory for the package and change into the directory.

Generate the empty NPM package.json file with the command and follow the prompts:

npm init


Create an index.js file and place the code for your module into it, such as:



Add README with usage instructions.

Add any dependencies via commands such as:

npm install --save moment


Publish on the NPM registry with the command:

npm publish


And now you can install it and call it from any of your applications, such as: