NODE JS

How to make module in NODE JS || How to use module in NODE JS

  • Neel Bhardwaj

  • 15-Jan-2022

  • 0 comments

  • 113

In this, we define module is created in file_1.js and use in file_2.js

for use the one file into another then i use the REQUIRE.

 

file_1.js

==============================

var sum = function(a,b){

        return a+b;

}

module.exports = sum;


 

file_2.js

==============================

var result = require('./file_1');

console.log(result(1,2));

"Programming isn't about what you know,
it's about what you can figure out.”
Chris Pine

Neel Bhardwaj

A full stack developer. I have a Passion for Creating Clean, Beautiful, Interactive, Minimalistic, Responsive and User Friendly website, Developed by Modular, Scalable and Functional Code.

Recent comments

Leave a reply