0% found this document useful (0 votes)
5 views1 page

Node.js Module Programming Guide

Uploaded by

sherrylruth04
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Node.js Module Programming Guide

Uploaded by

sherrylruth04
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Module programming in Nodejs:

-----------------------------
-> Consider modules to be the same as javaScript libraries.
-> A ser of functions you want to include in your application.
-> In [Link] we have two types of modules.
a) User Defined Modules
b) Pre-Defined Modules

[Link]=function(x,y){ |
return x+y; |
}; |
[Link]=function(x,y){ |
return x-y; |
}; |-----------------> file name
"[Link]"
[Link]=function(x,y){ |
return x*y; |
}; |
[Link]=function(x,y){ |
return x/y; |
}; |
-----------------------------------------------------------------------------------
-----------------------------
const calculator = requirs("./mod");
let x=30, y=10;
[Link]("Addition of 50 and 10is"+[Link](x,y));
[Link]("Addition of 50 and 10is"+[Link](x,y));
[Link]("Addition of 50 and 10is"+[Link](x,y));
[Link]("Addition of 50 and 10is"+[Link](x,y));

//Modules are exported using exports keyword.


//Modules are immported using require keyword.

Pre-Defined modules in Nodejs:


-----------------------------
The following table lists somr of the important predefined core modules in Nodejs.

Core Module Description


---- ------------------
http http module includes classes, methods, and events, to
create [Link] http server.
fs fs module includes classes methods and events to work
with file I/O.
url url module includes methods foe URL resolution and
parsing.
queryind queryiing module includes methods to deal with query
string.
path path module includes methods to deal with file paths
util util method includes utility methods which are

You might also like