Quantcast
Channel: Active questions tagged require - Stack Overflow
Viewing all articles
Browse latest Browse all 144

Require function returning an empty Object in NodeJS [closed]

$
0
0

I have 2 files to import an add function i made and execute it**math.js **

function add (a,b){    return a + b; } module.export = add();

Node1.js

const math = require("./math.js");console.log(marh(2,5);

i was expecting the result to be printed as 7 but instead i get an error saying math is not a function.

error msg printed :console.log(math(2,5));            ^TypeError: math is not a function

Viewing all articles
Browse latest Browse all 144

Trending Articles