Skip to main content

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

Core Modules Jump to heading

File System Jump to heading

Network & HTTP Jump to heading

Process & System Jump to heading

Crypto & Security Jump to heading

Data & Streams Jump to heading

Utilities Jump to heading

Development & Testing Jump to heading

Global Objects Jump to heading

Node.js global objects are available in the npm package scope and can be imported from relevant node: modules:

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:

Migration from Node.js Jump to heading

When migrating from Node.js to Deno:

  1. Update imports: Use node: prefix for built-in modules
  2. Check compatibility: Verify your dependencies work with Deno
  3. Use npm specifiers: Import npm packages with npm: prefix
  4. Review permissions: Configure Deno's permission system as needed

For more guidance, see our migration guide.