Saturday, 22 April 2017

Node js module.exports not exporting variable

i am new to node.js. I was working with module.exports and have certain doubt . I have two files

//test.js

module.exports.lm="abc";

module.exports = "hello";




//index.js

var p = require('./test.js');

var l = require('./test.js').lm;

console.log(p); //hello

console.log(l); //undefined

Can someone explain why this is happening.



via Harish Saini

No comments:

Post a Comment