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.
node: prefix
(e.g., import fs from "node:fs")node:fs - File system operations (read, write, watch, stats)node:fs/promises - Promise-based file system APInode:path - Cross-platform path utilitiesnode: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 functionsnode:process - Process information and controlnode:os - Operating system utilities and informationnode:child_process - Spawn and manage child processesnode:cluster - Multi-process clustering supportnode:crypto - Cryptographic functionality (hashing, encryption,
certificates)node:tls - TLS/SSL secure communication layernode:stream - Stream interfaces (readable, writable, transform)node:buffer - Binary data handling with Buffer classnode:zlib - Data compression and decompressionnode:string_decoder - Decode buffers to stringsnode: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 supportnode:vm - Virtual machine contexts for code executionnode:repl - Read-Eval-Print Loop functionalitynode:inspector - V8 inspector integration for debuggingNode.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 informationfetch, URL, TextEncoder, crypto, and moreimport 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");
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");
});
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);
Node compatibility is an ongoing project. Most core Node.js APIs are supported with high fidelity. For detailed compatibility information:
When migrating from Node.js to Deno:
node: prefix for built-in modulesnpm: prefixFor more guidance, see our migration guide.