Accounts you'll needNPM Registry GitHub
Tools you'll need installedText 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 init.author.name "Your name"
npm set init.author.email "firstname.lastname@example.org"
npm set init.author.url "http://www.yourhomepage.com"
Run the following command to login to the NPM registry:
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:
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:
And now you can install it and call it from any of your applications, such as: