JavaScript

Core Modules in Node.js

This blog post provides an overview of the core modules of the Node.js platform.

  • assert: This is the testing module of Node.js used to cover the platform itself with unit tests.
  • async_hooks: This module allows and simplifies the tracking of asynchronous resources during their lifecycle.
  • buffer: This module helps to handle binary data for the file system or network operations.
  • child_process: This module allows you to create and control child processes and communicate between processes.
  • cluster: This module is an extension of the child_process module for dynamic load balancing between processes.
  • console: This module represents a wrapper around the standard output.
  • crypto: This module provides encryption under Node.js.
  • dgram: This module enables you to establish User Datagram Protocol (UDP) connections and communicate through them.
  • dns: This module resolves names via Domain Name System (DNS). domain This module deals with grouping operations and handling errors that occur.
  • events: The events module provides the infrastructure for registering and triggering events.
  • fs: The fs module is used to gain both read and write access to the system’s file system.
  • http: This module helps you create HTTP clients and servers.
  • http2: With this module, the HTTP/2 protocol is now natively supported by Node.js. HTTP/2 represents a further development of HTTP.
  • https: This module enables encrypted communication both as HTTP client and server.
  • inspector: This module represents the interface to the V8 inspector. modules With this module, the Node.js module system is itself implemented as a module.
  • net: This module is the basis for network servers and clients.
  • os: This module allows you to read information about the operating system. path This module contains all the important operations for handling directory paths.
  • perf_hooks: This module allows you to make highly accurate time measurements in your application.
  • process: What the os module is to the operating system, the process module is to the current Node.js process.
  • punycode: This module deals with the standard-compliant conversion of Unicode characters to ASCII characters.
  • querystring: This module greatly simplifies the handling of query strings in URLs. readline Due to this module, a stream can be consumed line by line.
  • repl: This module represents the read-eval-print loop (REPL), which is the command line of Node.js.
  • stream: This module API provides different types of data streams.
  • string_decoder: This module can be used to convert buffer objects into strings. timers This module contains all time-based functions.
  • tls: This module is the interface to the public/private key infrastructure for secure communication.
  • trace_events: With this module, tracing information from the V8 engine, the Node platform as well as customized tracing information from the user can be processed centrally.
  • tty: This module represents the connection to the terminal, for example, the standard input and output.
  • url: This module is used to generate or parse URLs.
  • util: This module collects helpful functions such as type queries, formatting, and the like.
  • v8: This module enables you to work directly with the V8 engine. vm This module provides an environment for executing JavaScript code.
  • wasi: This module can be used to integrate WebAssembly modules or entire applications into Node.js. The module represents an implementation of the WebAssembly system interface specification.
  • worker_threads: In addition to the child_process module, this module helps to offload routines from the main process. The focus of the worker_threads module is on CPU-intensive calculations.
  • zlib: This module deals with the compression and decompression of information. 

Some of the modules presented here serve as an interface to the operating system, such as the net or fs modules. Others implement protocols or define commonly used structures such as the http modules or the events module. The latter are often used by Node.js itself to build other core modules. Parts of the fs module, for example, use the stream module to map data streams; this module in turn is based on the events module.

 

Editor’s note: This post has been adapted from a section of the book Node.js: The Comprehensive Guide by Sebastian Springer.

Recommendation

Node.js
Node.js

If you’re developing server-side JavaScript applications, you need Node.js! Start with the basics of the Node.js environment: installation, application structure, and modules. Then follow detailed code examples to learn about web development using frameworks like Express and Nest. Learn about different approaches to asynchronous programming, including RxJS and data streams. Details on peripheral topics such as testing, security, and performance make this your all-in-one daily reference for Node.js!

Learn More
Rheinwerk Computing
by Rheinwerk Computing

Rheinwerk Computing is an imprint of Rheinwerk Publishing and publishes books by leading experts in the fields of programming, administration, security, analytics, and more.

Comments