Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Create Your Own Node Module

mycoolmodule/index.js
export.a = "AAAAAA;
exports.hw = function() {
  console.log("Hello World!");
}
/*you can exports as many variables and functions as you want*/

routes/index.js
var express = require('express');

var mymodule = require('mycoolmodule')

var router = express.Router();

/* GET home page. */
router.get('/', function(req, res, next) {
	mymodule.hw();
/*	console.log(mymodule.a) will yield AAAAAA*/
});
 
module.exports = router;
 
PREVIOUS NEXT
Tagged: #Create #Your #Own #Node #Module
ADD COMMENT
Topic
Name
6+2 =