Core Modules
Core modules are built into Node.js. You do not need to install them. They cover the most common backend tasks: reading files, making HTTP requests, working with paths, and more.
Main core modules
| Module | What it does |
|---|---|
fs | Read, write, and manage files and directories |
path | Parse and join file system paths across platforms |
http / https | Create HTTP(S) servers and make requests |
url | Parse and work with URLs |
os | Access operating system information (platform, CPU, memory) |
events | Implement event emitters (Node observer pattern) |
stream | Work with readable and writable data streams |
querystring | Parse query string data |
child_process | Spawn external processes |
crypto | Encrypt and hash data |
util | Utility functions, including promisify for converting callbacks to promises |
assert | Assertion-based testing helpers |
net | Low-level networking (TCP/IPC) |
Importing core modules
No installation needed. Import by name.
CommonJS:
const fs = require('fs');
const path = require('path');
const http = require('http');
ES modules:
import fs from 'fs';
import path from 'path';
import http from 'http';
Modern Node.js also supports the node: prefix. This is recommended in newer code because it makes it clear you are importing a built-in module rather than an npm package with the same name:
import fs from 'node:fs';
import path from 'node:path';
import http from 'node:http';
For more detail on each module, see the Node.js documentation .
What to read next
- File System
: reading and writing files with
fs - Path Module
: joining and parsing file paths with
path - OS Module
: getting system information with
os - URL Module
: parsing URLs with the
urlmodule - HTTP Server
: creating a web server with
http