Files
bun.sh/docs/runtime/nodejs-apis.md

33 KiB

Bun aims for complete Node.js API compatibility. Most npm packages intended for Node.js environments will work with Bun out of the box; the best way to know for certain is to try it.

This page is updated regularly to reflect compatibility status of the latest version of Bun. If you run into any bugs with a particular package, please open an issue. Opening issues for compatibility bugs helps us prioritize what to work on next.

Built-in modules

node:assert

🟢 Fully implemented.

node:async_hooks

🟡 Only AsyncLocalStorage, and AsyncResource are implemented.

node:buffer

🟢 Fully implemented.

node:child_process

🟡 Missing IPC, Stream stdio, proc.gid, proc.uid, advanced serialization.

node:cluster

🔴 Not implemented.

node:console

🟢 Recommended to use console global instead

node:crypto

🟡 Missing crypto.Certificate crypto.ECDH crypto.KeyObject crypto.X509Certificate crypto.checkPrime{Sync} crypto.createPrivateKey crypto.createPublicKey crypto.createSecretKey crypto.diffieHellman crypto.generateKey{Sync} crypto.generateKeyPair{Sync} crypto.generatePrime{Sync} crypto.getCipherInfo crypto.{get|set}Fips crypto.hkdf crypto.hkdfSync crypto.secureHeapUsed crypto.setEngine crypto.sign crypto.verify. Some methods are not optimized yet.

node:dgram

🔴 Not implemented.

node:diagnostics_channel

🟢 Fully implemented.

node:dns

🟢 Fully implemented.

node:domain

🟢 Fully implemented.

node:events

🟡 Missing on

node:fs

🟡 Missing fs.fdatasync{Sync} fs.opendir{Sync}. fs.promises.open incorrectly returns a file descriptor instead of a FileHandle.

node:http

🟢 Fully implemented.

node:http2

🔴 Not implemented.

node:https

🟢 Fully implemented.

node:inspector

🔴 Not implemented.

node:module

🟢 Fully implemented.

node:net

🟡 Missing net.{get|set}DefaultAutoSelectFamily net.SocketAddress net.BlockList.

node:os

🟢 Fully implemented.

node:path

🟢 Fully implemented.

node:perf_hooks

🟡 Only perf_hooks.performance.now() and perf_hooks.performance.timeOrigin are implemented. Recommended to use performance global instead of perf_hooks.performance.

node:process

🟡 See Globals > process.

node:punycode

🟢 Fully implemented. Deprecated by Node.js.

node:querystring

🟢 Fully implemented.

node:readline

🟢 Fully implemented.

node:repl

🔴 Not implemented.

node:stream

🟢 Fully implemented.

node:string_decoder

🟢 Fully implemented.

node:sys

🟡 See node:util.

node:timers

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

node:tls

🟡 Missing tls.createSecurePair

node:trace_events

🔴 Not implemented.

node:tty

🟢 Fully implemented.

node:url

🟡 Missing url.domainTo{ASCII|Unicode}. Recommended to use URL and URLSearchParams globals instead.

node:util

🟡 Missing util.MIMEParams util.MIMEType util.formatWithOptions() util.getSystemErrorMap() util.getSystemErrorName() util.parseArgs() util.stripVTControlCharacters() util.transferableAbortController() util.transferableAbortSignal().

node:v8

🔴 serialize and deserialize use JavaScriptCore's wire format instead of V8's. Otherwise, not implemented. For profiling, use bun:jsc instead.

node:vm

🟡 Core functionality works, but VM modules are not implemented. ShadowRealm can be used.

node:wasi

🟡 Partially implemented.

node:worker_threads

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

node:zlib

🟡 Missing zlib.brotli*. Some methods are not optimized.

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

🟡 Incomplete implementation of base64 and base64url encodings.

ByteLengthQueuingStrategy

🟢 Fully implemented.

__dirname

🟢 Fully implemented.

__filename

🟢 Fully implemented.

atob()

🟢 Fully implemented.

BroadcastChannel

🟢 Fully implemented.

btoa()

🟢 Fully implemented.

clearImmediate()

🟢 Fully implemented.

clearInterval()

🟢 Fully implemented.

clearTimeout()

🟢 Fully implemented.

CompressionStream

🔴 Not implemented.

console

🟡 Missing Console constructor.

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. Added in Bun 0.5.7.

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

🔴 Not implemented.

PerformanceMark

🔴 Not implemented.

PerformanceMeasure

🔴 Not implemented.

PerformanceObserver

🔴 Not implemented.

PerformanceObserverEntryList

🔴 Not implemented.

PerformanceResourceTiming

🔴 Not implemented.

performance

🟢 Fully implemented.

process

🟡 Missing process.allowedNodeEnvironmentFlags process.channel() process.connected process.constrainedMemory() process.disconnect() process.getActiveResourcesInfo/setActiveResourcesInfo() process.setuid/setgid/setegid/seteuid/setgroups() process.hasUncaughtExceptionCaptureCallback process.initGroups() process.report process.resourceUsage() process.send().

queueMicrotask()

🟢 Fully implemented.

ReadableByteStreamController

🟢 Fully implemented.

ReadableStream

🟢 Fully implemented.

ReadableStreamBYOBReader

🔴 Not implemented.

ReadableStreamBYOBRequest

🔴 Not implemented.

ReadableStreamDefaultController

🟢 Fully implemented.

ReadableStreamDefaultReader

🟢 Fully implemented.

require()

🟢 Fully implemented, as well as require.main, require.cache, and 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

🔴 Not implemented.

TextEncoder

🟢 Fully implemented.

TextEncoderStream

🔴 Not 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.