3 Program to use Modules in NodeJS

Program:

square.js:

var calculate_square = function(number){

    console.log(number*number);

}



module.exports = calculate_square;


app.js:

var calculate_square = require('./square')

calculate_square(5)


Output:

Modules in NodeJS

Previous
Next Post »