Node.js has several built-in core modules to help you perform various tasks without the need to install external libraries. Here are some of the most commonly used core modules:
1. **fs** - File System Module
This module allows you to interact with the file system on a server, such as reading, writing, updating, or deleting files. Example syntax:
const fs = require('fs');
2. **http** - HTTP Module
This module allows you to create an HTTP server to handle incoming requests and send responses. Example syntax:
const http = require('http');
3. **https** - HTTPS Module
This module is similar to the HTTP module but provides support for HTTPS connections (secured with SSL/TLS). Example syntax:
const https = require('https');
4. **url** - URL Module
This module provides utilities for URL resolution and parsing, allowing you to easily manipulate and analyze URLs. Example syntax:
const url = require('url');
5. **path** - Path Module
This module provides utilities to work with file and directory paths, making it easier to access and manipulate paths across different operating systems. Example syntax:
const path = require('path');
6. **events** - EventEmitter Module
This module facilitates using event-driven programming patterns in your applications. It allows you to create, emit, and listen to custom event signals. Example syntax:
const EventEmitter = require('events');
7. **stream** - Stream Module
This module provides a way to handle streaming data (data transferred in chunks), such as reading or writing data to files, network communications, or other data streams. Example syntax:
const stream = require('stream');
8. **querystring** - Query String Module
This module provides utilities to parse and stringify query strings, allowing you to create and manipulate query strings in URLs. Example syntax:
const querystring = require('querystring');
9. **os** - Operating System Module
This module provides information about the server’s operating system, such as the total memory, available memory, CPU architecture, and more. Example syntax:
const os = require('os');
10. **buffer** - Buffer Module
This module deals with binary data, allowing you to create and manipulate binary data buffers. Example syntax:
const Buffer = require('buffer').Buffer;
These are just a few of the many built-in core modules in Node.js. You can find the full list of core modules in the [Node.js documentation](https://nodejs.org/api/index.html).