Installation

npm

-- save : to install package and save it as a dependency in the package.json file

$ npm install npm-demo-testing-maz --save

Test

create anyfile on js for example index.js. replace code on below

var demo = require('npm-demo-testing-maz');
demo.printMsg();

run command

$ node index.js

Usage

Tutorial to develop node module

$ npm init

create index.js

exports.printMsg = function() {
console.log("This is a message from the demo package");
}

push to git

$ git add.
$ git commit -m "Initial release"
$ git tag v0.0.1 
$ git push origin master --tags

publish to npm package

** if not login or havent user yet

npm register user

$ npm add user 

npm login

$ npm login

publish

$ npm publish

More learn about create node js module - link: https://www.guru99.com/node-js-modules-create-publish.html