In foo.js
module.exports.double = function(x) {
return x * 2;
};
var triple = function(x) {
return x * 3;
};
In bar.js
var foo = require('./foo');
var z = foo.double(5);
console.log(z);
var q = foo.triple(5) // ERROR!
Commands to master:
$ npm search $ npm install [-g] $ npm init
search, install, require
{
"name": "totter",
"version": "0.0.1",
"description": "Demonstration module for TotT",
"main": "index.js",
"scripts": {
"test": "mocha"
},
"repository": {
"type": "git",
"url": "git@bitbucket.org:unctott/totter.git"
},
"keywords": [
"teaching",
"tott",
"unc"
],
"author": "Peter Parente",
"license": "BSD",
"dependencies": {
"jade": "~0.27.6",
"markdown": "~0.4.0"
}
}
npm, package.json, colors
In sessions about frontend JS