nodejs, i cant module.exports more than 1 function

if i do:


 module.exports = mongoConnect;
 module.exports = getDb;

and than

const mongoConnect = require('./util/database').mongoConnect;

ERROR: mongoConnect is not a function if i do console.log(mongoConnect): ill get [Function: getDb]

but if i export like this:

module.exports = {

than in /app.js

console.log(mongoConnect): { mongoConnect: [Function: mongoConnect], getDb: [Function: getDb] }

why in the first case it doesn't work?

Read more here:

Content Attribution

This content was originally published by amine ahardane at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: