On this page
Node.js Built-in APIs
Deno provides comprehensive support for Node.js built-in modules and globals, enabling seamless migration of Node.js applications and libraries. These APIs follow Node.js specifications and provide familiar functionality for developers transitioning from Node.js.
Key Features Jump to heading
- Built-in Module Support: Access Node.js modules using
node:
prefix (e.g.,import fs from "node:fs"
) - Global Objects: Node.js global objects available in npm package scope
- Compatibility Layer: Seamless interoperability with existing Node.js code
- Performance: Native implementations optimized for Deno runtime
Core Modules Jump to heading
File System Jump to heading
node:fs
- File system operations (read, write, watch, stats)node:fs/promises
- Promise-based file system APInode:path
- Cross-platform path utilities
Network & HTTP Jump to heading
node:http
- HTTP server and client functionalitynode:https
- HTTPS server and client with TLS supportnode:http2
- HTTP/2 server and client implementationnode:net
- TCP networking utilitiesnode:dns
- DNS resolution and lookup functions
Process & System Jump to heading
node:process
- Process information and controlnode:os
- Operating system utilities and informationnode:child_process
- Spawn and manage child processesnode:cluster
- Multi-process clustering support
Crypto & Security Jump to heading
node:crypto
- Cryptographic functionality (hashing, encryption, certificates)node:tls
- TLS/SSL secure communication layer
Data & Streams Jump to heading
node:stream
- Stream interfaces (readable, writable, transform)node:buffer
- Binary data handling with Buffer classnode:zlib
- Data compression and decompressionnode:string_decoder
- Decode buffers to strings
Utilities Jump to heading
node:util
- Utility functions (promisify, inspect, types)node:events
- Event emitter pattern implementationnode:url
- URL parsing and formatting utilitiesnode:querystring
- Query string utilitiesnode:assert
- Assertion testing support
Development & Testing Jump to heading
node:vm
- Virtual machine contexts for code executionnode:repl
- Read-Eval-Print Loop functionalitynode:inspector
- V8 inspector integration for debugging
Global Objects Jump to heading
Node.js global objects are available in the npm package scope and can be
imported from relevant node:
modules:
Buffer
- Binary data manipulationprocess
- Process information and environmentglobal
- Global namespace object__dirname
/__filename
- Module path information- Web Standards -
fetch
,URL
,TextEncoder
,crypto
, and more
Usage Examples Jump to heading
Basic Module Import Jump to heading
import fs from "node:fs";
import { readFile } from "node:fs/promises";
import path from "node:path";
// Synchronous file reading
const data = fs.readFileSync("file.txt", "utf8");
// Asynchronous file reading
const content = await readFile("file.txt", "utf8");
// Path manipulation
const fullPath = path.join("/users", "documents", "file.txt");
HTTP Server Jump to heading
import http from "node:http";
const server = http.createServer((req, res) => {
res.writeHead(200, { "Content-Type": "text/plain" });
res.end("Hello from Node.js API in Deno!");
});
server.listen(3000, () => {
console.log("Server running on port 3000");
});
Crypto Operations Jump to heading
import crypto from "node:crypto";
// Generate hash
const hash = crypto.createHash("sha256");
hash.update("Hello World");
const digest = hash.digest("hex");
// Generate random bytes
const randomBytes = crypto.randomBytes(16);
Compatibility Jump to heading
Node compatibility is an ongoing project. Most core Node.js APIs are supported with high fidelity. For detailed compatibility information:
- View our Node.js compatibility guide
- Check Node.js test results for specific test coverage
- Report compatibility issues on GitHub
Migration from Node.js Jump to heading
When migrating from Node.js to Deno:
- Update imports: Use
node:
prefix for built-in modules - Check compatibility: Verify your dependencies work with Deno
- Use npm specifiers: Import npm packages with
npm:
prefix - Review permissions: Configure Deno's permission system as needed
For more guidance, see our migration guide.