0

i'm new with Node.js and begin my training but stuck with the console behavior. i try to attach tutorial.js module with app.js so it will display all functions in tutorial.js module.

tutorial.js

const sum = (num1,num2) => num1 + num2;
const div = (num1,num2) => num1 / num2;
module.expose=sum;
module.expose=div;

app.js

const tutorial = require('./tutorial');
console.log(tutorial);

console.log(tutorial) display empty module -

node app.js
{}

what am i doing wrong?

Tzahi Kadosh
  • 399
  • 2
  • 8
  • 20

1 Answers1

1

You have to use module.exports not module.expose

const sum = (num1,num2) => num1 + num2;
    const div = (num1,num2) => num1 / num2;
    module.exports=sum;
    module.exports=div;

For more details look at this answer

Shubh
  • 8,368
  • 4
  • 18
  • 39