• Register

Share:- Whatsapp Facebook Facebook

------------------------------------- Welcome to Developerhelpway Q&A, where you can ask questions and receive answers from other members of the community.

Categories

0 votes
11 views
What is module.exports in node js? Explain with an example.
in Node.js by (4.4k points)

1 Answer

0 votes
The module.exports:- The method or variable is defined in modules that cannot be directly accessible by the outer world, that means you cannot call a module member from the external file.
To access module member, we need to export the functions or variables of modules using module.exports method.

Syntax and usage:

// hello.js
var message=function(){
console.log("hello World");
}
module.exports=message;

//In app.js

var message=require('./message.js');
message();
by (4.4k points)
...