Hello @kartik,
In your db.js, export the init function. There are many ways, but for example:
module.exports.init = function () {
console.log('hi');
};
Then call it like this, assuming your db.js is in the same directory as your command prompt:
node -e 'require("./db").init()'
To other readers, the OP's init function could have been called anything, it is not important, it is just the specific name used in the question.
Hope it helps!!
To know more about it, enroll in Node.js training today.
Thank You!!