I\'m writing a web app in Node. If I\'ve got some JS file db.js with a function init in it how could I call that function from the command line?
db.js
init
If you turn db.js into a module you can require it from db_init.js and just: node db_init.js.
db_init.js
node db_init.js
db.js:
module.exports = { method1: function () { ... }, method2: function () { ... } }
db_init.js:
var db = require('./db'); db.method1(); db.method2();