- Sep 30, 2018
- admin
- 0
Node.js Modules:
Modules are the files in Node.js used for grouping similar codes, to get an easy access to those codes. Node.js Modules facilitates reusability and easy categorization of codes.
-
Node.js Built In Modules:
Node.js facilitates its users a variety of modules already defined in Node.js library that makes Node.js an easy to use programming language. It is a lightweight framework with very less modules. Some of these modules are:
| MODULE | USES |
| zlib | Used to compress or decompress Node.js files. |
| vm | Used to compile JavaScript code in a virtual machine. |
| v8 | Used to access information about V8 JavaScript engine. |
| util | Used to access utility functions in Node.js. |
| url | Used to parse URL strings in Node.js. |
| tls | Used to implement TLS and SSL protocols in Node.js. |
| tty | Used to get classes used by a text terminal in Node.js. |
| timers | Used to execute a function after a given number of milliseconds in Node.js. |
| string_decoder | Used to decode buffer objects into strings in Node.js. |
| stream | Used to handle streaming data in Node.js. |
| readline | Used to handle readable streams line by line in Node.js. |
| querystrings | Used to handle URL query string in Node.js. |
| path | Used to handle file paths in Node.js. |
| punycode | Used as a character encoding scheme in Node.js. |
| os | Used to get information about the operation system. |
| net | Used to create servers and clients in Node.js. |
| https | Used to make Node.js act as an HTTPS server. |
| http | Used to make Node.js act as an HTTP server. |
| fs | Used to handle the file system in Node.js. |
| events | Used to handle events in Node.js. |
| domain | Used to handle unhandled errors in Node.js. |
| dns | Used to do DNS lookups and name resolution functions. |
| dgram | Used to get implementation of UDP datagram sockets. |
| crypto | Used to handle OpenSSL cryptographic functions in Node.js. |
| cluster | Used to split a single Node process into multiple processes. |
| child_process | Used to run a child process in Node.js. |
| buffer | Used to handle binary data in Node.js. |
| assert | Used to get a set of assertion tests. |
To include a Node.js Built In Module:
Node.js require() function with the name of the module is used.
Syntax:
var variable_name = require(‘module_name’);
● Node.js User Defined Modules:
Node.js also facilitates its users to create their own modules using export keyword.
To include a Node.js User Defined Module:
Node.js require() function with the name of the module is used.
Syntax:
var variable_name = require(‘module_name’);
Tags: NodeJS Modules, NodeJS Tutorial