Files
bun.sh/docs/runtime/nodejs-apis.md
Claude Bot 6c357697b4 docs: clean up redundant and defensive language
- Remove '(not no-ops)' defensive language from module section
- Remove '(stub implementation)' redundant technical details
- Remove 'complete statistical analysis capabilities' unnecessary detail
- Remove 'comprehensive', 'Zero-cost when not in use, optimized for production workloads' marketing language
- Remove 'Mostly Complete', 'Minor limitations', 'easy fix' implementation details
- Simplify child_process from bullet points to single sentence

Focus on what users need to know about compatibility, not implementation details.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-05 23:22:17 +00:00

17 KiB

Every day, Bun gets closer to 100% Node.js API compatibility. Today, popular frameworks like Next.js, Express, and millions of npm packages intended for Node just work with Bun. To ensure compatibility, we run thousands of tests from Node.js' test suite before every release of Bun.

If a package works in Node.js but doesn't work in Bun, we consider it a bug in Bun. Please open an issue and we'll fix it.

This page is updated regularly to reflect compatibility status of the latest version of Bun. The information below reflects Bun's compatibility with Node.js v23.

Built-in Node.js modules

node:assert

🟢 Fully implemented.

node:buffer

🟢 Fully implemented.

node:console

🟢 Fully implemented.

node:dgram

🟢 Fully implemented. > 90% of Node.js's test suite passes.

node:diagnostics_channel

🟢 Fully implemented.

node:dns

🟢 Fully implemented. > 90% of Node.js's test suite passes.

node:events

🟢 Fully implemented. 100% of Node.js's test suite passes. EventEmitterAsyncResource uses AsyncResource underneath.

node:fs

🟢 Fully implemented. 92% of Node.js's test suite passes.

node:http

🟢 Fully implemented. Outgoing client request body is currently buffered instead of streamed.

node:https

🟢 APIs are implemented, but Agent is not always used yet.

node:os

🟢 Fully implemented. 100% of Node.js's test suite passes.

node:path

🟢 Fully implemented. 100% of Node.js's test suite passes.

node:punycode

🟢 Fully implemented. 100% of Node.js's test suite passes, deprecated by Node.js.

node:querystring

🟢 Fully implemented. 100% of Node.js's test suite passes.

node:readline

🟢 Fully implemented.

node:stream

🟢 Fully implemented.

node:string_decoder

🟢 Fully implemented. 100% of Node.js's test suite passes.

node:timers

🟢 Recommended to use global setTimeout, et. al. instead.

node:tty

🟢 Fully implemented.

node:url

🟢 Fully implemented.

node:zlib

🟢 Fully implemented. 98% of Node.js's test suite passes.

node:async_hooks

🟡 AsyncLocalStorage is fully implemented. AsyncResource and EventEmitterAsyncResource have core functionality but lifecycle methods return stubs. createHook, Promise Hooks, and Async ID tracking are not implemented.

node:child_process

🟢 All core child_process functions (spawn, exec, fork, etc.) are fully implemented. Missing proc.gid/proc.uid properties, Stream base class not exported, and IPC cannot send socket handles/file descriptors.

node:cluster

🟡 Worker process management, IPC communication, and round-robin load balancing are implemented. Handle/file descriptor passing not implemented (blocks SCHED_NONE scheduling). Direct socket sharing unavailable on all platforms. HTTP load balancing requires SO_REUSEPORT (Linux only) or external load balancer. Works for basic clustering, message passing, process management but not high-performance socket sharing or Windows/macOS HTTP clustering.

node:crypto

🟡 secureHeapUsed returns undefined instead of heap stats object. setFips lacks input validation. Reduced algorithm support compared to Node.js (10 vs 52 hashes, 28 vs 127 ciphers, 4 vs 82 curves).

node:domain

🟡 Missing Domain constructor class and active property for domain context tracking. Core domain functionality is implemented.

node:http2

🟡 Client & server are implemented with recent gRPC compatibility improvements. Missing options.allowHTTP1, options.enableConnectProtocol, and http2stream.pushStream. ALTSVC extension is implemented.

node:module

🟡 Missing syncBuiltinESMExports, Module#load(), and module.register. Overriding require.cache is fully supported. module._extensions, module._pathCache, module._cache work correctly and custom extensions can be registered. Use Bun.plugin instead of module.register.

node:net

🟢 Fully implemented.

node:perf_hooks

🟡 Missing monitorEventLoopDelay. createHistogram is fully implemented. perf_hooks.performance provides Node.js-specific features like nodeTiming and eventLoopUtilization not available on the global performance object.

node:process

🟡 See process Global.

node:sys

🟡 See node:util.

node:tls

🟡 Missing deprecated tls.createSecurePair() function. All modern TLS functionality is fully implemented.

node:util

🟡 Minor gaps: Missing newer functions getCallSite getCallSites (v22.9.0+), getSystemErrorMap (v16.0.0+), getSystemErrorMessage (v23.1.0+), transferableAbortSignal transferableAbortController, internal utilities _errnoException _exceptionWithHostPort, and diff. All core util functions and util/types module are fully implemented with ~98% test pass rate.

node:v8

🟡 writeHeapSnapshot, getHeapSnapshot, and basic serialize/deserialize are implemented using JavaScriptCore. Most other V8-specific APIs are not implemented. Use bun:jsc for profiling instead.

node:vm

🟡 Core functionality and ES modules are implemented, including vm.Script, vm.createContext, vm.runInContext, vm.runInNewContext, vm.runInThisContext, vm.compileFunction, vm.isContext, vm.Module, vm.SourceTextModule, vm.SyntheticModule, and importModuleDynamically support. Options like timeout and breakOnSigint are fully supported. Missing vm.measureMemory and some cachedData functionality.

node:wasi

🟡 WASI is implemented in JavaScript with basic functionality. Not all WASI specification features are supported yet.

node:worker_threads

🟡 Worker doesn't support the following options: stdin stdout stderr trackedUnmanagedFds resourceLimits. Missing markAsUntransferable moveMessagePortToContext getHeapSnapshot.

node:inspector

🟡 Basic stub exists. Inspector infrastructure is implemented but Node.js API compatibility layer is not connected yet.

node:repl

🟡 bun repl CLI command works but node:repl module API is not implemented. Use bun repl instead.

node:sqlite

🔴 Not implemented. Use bun:sqlite instead.

node:test

🟡 Partly implemented. Missing mocks, snapshots, timers. Use bun:test instead.

node:trace_events

🟡 Basic stub exists. Extensive internal tracing system implemented but Node.js API compatibility layer is minimal.

Node.js globals

The table below lists all globals implemented by Node.js and Bun's current compatibility status.

AbortController

🟢 Fully implemented.

AbortSignal

🟢 Fully implemented.

Blob

🟢 Fully implemented.

Buffer

🟢 Fully implemented.

ByteLengthQueuingStrategy

🟢 Fully implemented.

__dirname

🟢 Fully implemented.

__filename

🟢 Fully implemented.

atob()

🟢 Fully implemented.

Atomics

🟢 Fully implemented.

BroadcastChannel

🟢 Fully implemented.

btoa()

🟢 Fully implemented.

clearImmediate()

🟢 Fully implemented.

clearInterval()

🟢 Fully implemented.

clearTimeout()

🟢 Fully implemented.

CompressionStream

🔴 Not implemented.

console

🟢 Fully implemented.

CountQueuingStrategy

🟢 Fully implemented.

Crypto

🟢 Fully implemented.

SubtleCrypto (crypto)

🟢 Fully implemented.

CryptoKey

🟢 Fully implemented.

CustomEvent

🟢 Fully implemented.

DecompressionStream

🔴 Not implemented.

Event

🟢 Fully implemented.

EventTarget

🟢 Fully implemented.

exports

🟢 Fully implemented.

fetch

🟢 Fully implemented.

FormData

🟢 Fully implemented.

global

🟢 Implemented. This is an object containing all objects in the global namespace. It's rarely referenced directly, as its contents are available without an additional prefix, e.g. __dirname instead of global.__dirname.

globalThis

🟢 Aliases to global.

Headers

🟢 Fully implemented.

MessageChannel

🟢 Fully implemented.

MessageEvent

🟢 Fully implemented.

MessagePort

🟢 Fully implemented.

module

🟢 Fully implemented.

PerformanceEntry

🟢 Fully implemented.

PerformanceMark

🟢 Fully implemented.

PerformanceMeasure

🟢 Fully implemented.

PerformanceObserver

🟢 Fully implemented.

PerformanceObserverEntryList

🟢 Fully implemented.

PerformanceResourceTiming

🟢 Fully implemented.

performance

🟢 Fully implemented.

process

🟡 Mostly implemented. process.binding (internal Node.js bindings some packages rely on) is partially implemented. process.title is currently a no-op on macOS & Linux. getActiveResourcesInfo setActiveResourcesInfo, getActiveResources and setSourceMapsEnabled are stubs. Newer APIs like process.loadEnvFile and process.getBuiltinModule are not implemented yet.

queueMicrotask()

🟢 Fully implemented.

ReadableByteStreamController

🟢 Fully implemented.

ReadableStream

🟢 Fully implemented.

ReadableStreamBYOBReader

🟢 Fully implemented.

ReadableStreamBYOBRequest

🟢 Fully implemented.

ReadableStreamDefaultController

🟢 Fully implemented.

ReadableStreamDefaultReader

🟢 Fully implemented.

require()

🟢 Fully implemented, including require.main, require.cache, require.resolve.

Response

🟢 Fully implemented.

Request

🟢 Fully implemented.

setImmediate()

🟢 Fully implemented.

setInterval()

🟢 Fully implemented.

setTimeout()

🟢 Fully implemented.

structuredClone()

🟢 Fully implemented.

SubtleCrypto

🟢 Fully implemented.

DOMException

🟢 Fully implemented.

TextDecoder

🟢 Fully implemented.

TextDecoderStream

🟢 Fully implemented.

TextEncoder

🟢 Fully implemented.

TextEncoderStream

🟢 Fully implemented.

TransformStream

🟢 Fully implemented.

TransformStreamDefaultController

🟢 Fully implemented.

URL

🟢 Fully implemented.

URLSearchParams

🟢 Fully implemented.

WebAssembly

🟢 Fully implemented.

WritableStream

🟢 Fully implemented.

WritableStreamDefaultController

🟢 Fully implemented.

WritableStreamDefaultWriter

🟢 Fully implemented.