• Register

Share:- Whatsapp Facebook Facebook

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


0 votes
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");

//In app.js

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