Skip to content

Instantly share code, notes, and snippets.

Last active Dec 24, 2015
What would you like to do?
Node.js Module Globals Example
var b = require(__dirname + "/b"),
c = require(__dirname + "/c");
console.log(c.get()); //Outputs 'b.doIt is updating stuff!'
var c = require(__dirname + '/c');
module.exports.doIt = function() {
c.update("b.doIt is updating stuff!");
var x;
module.exports.update = function(y) {
x = y;
module.exports.get = function() {
return x;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment