”;
A module in Node.js is a collection of independent and reusable code that can be imported into any Node.js application. The Node.js runtime software comes with the V8 JavaScript engine, bundled with a number of core modules, that perform important server-side tasks, such as managing event loop, perform file IO and operating system-specific functions etc.
Example
The following code snippet returns a list of all the built-in modules −
const builtinModules = require(''repl'')._builtinLibs; console.log(builtinModules);
Output
[ ''assert'', ''assert/strict'', ''async_hooks'', ''buffer'', ''child_process'', ''cluster'', ''console'', ''constants'', ''crypto'', ''dgram'', ''diagnostics_channel'', ''dns'', ''dns/promises'', ''domain'', ''events'', ''fs'', ''fs/promises'', ''http'', ''http2'', ''https'', ''inspector'', ''inspector/promises'', ''module'', ''net'', ''os'', ''path'', ''path/posix'', ''path/win32'', ''perf_hooks'', ''process'', ''punycode'', ''querystring'', ''readline'', ''readline/promises'', ''repl'', ''stream'', ''stream/consumers'', ''stream/promises'', ''stream/web'', ''string_decoder'', ''sys'', ''timers'', ''timers/promises'', ''tls'', ''trace_events'', ''tty'', ''url'', ''util'', ''util/types'', ''v8'', ''vm'', ''wasi'', ''worker_threads'', ''zlib'' ]
Node.js has many core modules that provide essential functionalities for building applications. Here”s a list of some of the most important core modules −
Sr.No | Core Modules & Description |
---|---|
1 |
Provides a set of assertion functions for verifying invariants. |
2 |
A Buffer objects represent fixed-legth of sequence of bytes. |
3 |
http
Provides an interface for creating HTTP servers and making HTTP requests. |
4 |
fs
Provides functions for working with files and directories. |
5 |
Provides functions for working with file paths. |
6 |
Provides functions for parsing and building URLs. |
7 |
util
Provides utility functions for working with data and strings. |
8 |
crypto
Provides functions for cryptography and secure hashing. |
9 |
process
Provides information about the current Node.js process and allows you to interact with the operating system. |
10 |
net
Provides low-level networking functionality. |
11 |
stream
Provides a basic framework for working with streams of data. |
12 |
events
Provides an event emitter class for custom event handling. |
13 |
Provides functions for writing to the console. |
14 |
readline
Provides functions for reading line-by-line from a stream. |
15 |
Provides utilities for parsing and formatting URL query strings. |
16 |
Provides functions that are specific to the version of v8. |
17 |
Provides functions and properties related. |
”;