0.0.0 • Published 9 years ago
ssrfcom v0.0.0
Step by Step Process to write OWN NPM Module
Configure NPM :
npm set init.author.name "Mahmudul Hasan"
npm set init.author.email "sohel.official@gmail.com"
npm set init.author.url "NA"
npm adduser
Create/Clone git Repository
Create a git repository
Clone it in your desired location as follows :
git clone git@github.com:gitusername/project.git cd project
Then Execute : npm init
(This command will guide you through the process of generating the “package.json” file by QAquestion and answer)
Let's do the coding :
- Create index.js file as it's my starting point file for the module.
Example File :
exports.WhatAreyou=function(){
return "Hello i am your module";
};
- Now to test the module from javascript file. Let's write a test.js file. I did this for example
var req = require("./index.js");
console.log(req.WhatAreyou());
- Run the test file from node as
node test.js
It should show "Hello i am your module"
Now the module is ready . Let's commit it to git . Add tag for version and commit git tag 0.1.0 git push origin master –tags
Now we can install from git as :
npm install git://github.com/you/your_project.git npm install git://github.com/you/your_project.git#0.1.0
Check in the list of modules. It's Done !
0.0.0
9 years ago