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)
Steps
After ensuring that Node is installed, provide your details with the following commands in the terminal:
npm set init.author.name "Your name"
npm set init.author.email "your@email.com"
npm set init.author.url "http://www.yourhomepage.com"
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: