跳到主要內容

Node API 相容性清單

Deno 為許多內建 Node.js 模組和全域變數提供多重載入。Node 相容性是一個持續進行的專案 - 協助我們找出差距,並透過 在 GitHub 上開啟問題 讓我們知道您需要的模組。

內建模組支援

✅ = 完整支援
ℹ️ = 部分支援
❌ = 僅提供 Stub
node:assert

Fully supported.

Node.js docs

node:async_hooks
ℹ️

AsyncLocalStorage is supported. AsyncResource, executionAsyncId, and createHook are non-functional stubs.

Node.js docs

node:buffer

Fully supported.

Node.js docs

node:child_process
ℹ️

The ipc and overlapped stdio options are missing. Passing file descriptors by an integer value is missing.

Node.js docs

node:cluster

All exports are non-functional stubs.

Node.js docs

node:console

Fully supported.

Node.js docs

node:crypto
ℹ️

Missing Certificate class, crypto.Cipheriv.prototype.setAutoPadding, crypto.Decipheriv.prototype.setAutoPadding, crypto.getCipherInfo, crypto.publicDecrypt, crypto.ECDH.prototype.convertKey, crypto.diffieHellman, x448 option for generateKeyPair, crypto.KeyObject, safe, add and rem options for generatePrime, crypto.Sign.prototype.sign and crypto.Verify.prototype.verify with non BinaryLike input, crypto.secureHeapUsed, crypto.setEngine, legacy methods of crypto.X509Certificate.

Node.js docs

node:dgram
ℹ️

Some dgram.Socket instance methods are non-functional stubs:

  • addMembership
  • addSourceSpecificMembership
  • dropMembership
  • dropSourceSpecificMembership
  • setBroadcast
  • setMulticastInterface
  • setMulticastLoopback
  • setMulticastTtl
  • setTtl
  • ref
  • unref

Node.js docs

node:diagnostics_channel

Fully supported.

Node.js docs

node:dns
ℹ️

Missing dns.resolve* with ttl option.

Node.js docs

node:domain

All exports are non-functional stubs.

Node.js docs

node:events

Fully supported.

Node.js docs

node:fs
ℹ️
node:fs

Missing utf16le, latin1 and ucs2 encoding for fs.writeFile and fs.writeFileSync. Missing Dirent.isBlockDevice, Dirent.isCharacterDevice, Dirent.isFIFO, Dirent.isSocket, FSWatcher.ref, FSWatcher.unref.

node:fs/promises

Missing lchmod, lchown, lutimes.

Node.js docs

node:http
ℹ️

createConnection option is currently not supported.

Node.js docs

node:http2
ℹ️

Partially supported, major work in progress to enable grpc-js.

Node.js docs

node:https
ℹ️

Missing https.Server.opts.cert and https.Server.opts.key array type.

Node.js docs

node:inspector
ℹ️

console is supported. Other APIs are stubs and will throw an error. Due to security implications the Deno team does not plan to polyfill these APIs.

Node.js docs

node:module

Fully supported.

Node.js docs

node:net
ℹ️

Missing net.Socket.prototype.constructor with fd option.

Node.js docs

node:os

Fully supported.

Node.js docs

node:path

Fully supported.

Node.js docs

node:perf_hooks
ℹ️

Missing perf_hooks.eventLoopUtilization, perf_hooks.timerify, perf_hooks.monitorEventLoopDelay.

Node.js docs

node:punycode

Fully supported.

Node.js docs

node:process
ℹ️

Missing multipleResolves, worker events.

Node.js docs

node:querystring

Fully supported.

Node.js docs

node:readline

Fully supported.

Node.js docs

node:repl
ℹ️

builtinModules and _builtinLibs are supported. Missing REPLServer.prototype.constructor and start().

Node.js docs

node:stream

Fully supported.

Node.js docs

node:string_decoder
ℹ️

Missing decoding of ascii, latin1 and utf16le decoding options.

Node.js docs

node:sys

Fully supported.

Node.js docs

node:test
ℹ️

Currently only test API is supported.

Node.js docs

node:timers

Fully supported.

Node.js docs

node:tls
ℹ️

Missing createSecurePair.

Node.js docs

node:trace_events

All exports are non-functional stubs.

Node.js docs

node:tty
ℹ️

Missing ReadStream and WriteStream implementation.

Node.js docs

node:util
ℹ️

Missing aborted, transferableAbortSignal, transferableAbortController, MIMEParams, MIMEType, getSystemErrorMap, and debug.

Node.js docs

node:url

Fully supported.

Node.js docs

node:v8
ℹ️

cachedDataVersionTag and getHeapStatistics are supported. setFlagsFromStrings is a noop. Other APIs are not supported and will throw and error. The other APIs could be polyfilled, but due inherent lack of format stability between the V8 versions, the Deno team is considering requiring a special flag to use them.

Node.js docs

node:vm
ℹ️

runInThisContext is supported. Other APIs are not polyfilled and will throw and error.

Node.js docs

node:wasi

All exports are non-functional stubs.

Node.js docs

node:worker_threads
ℹ️

Missing parentPort.emit, parentPort.removeAllListeners, markAsUntransferable, moveMessagePortToContext, receiveMessageOnPort, Worker.prototype.getHeapSnapshot.

Node.js docs

node:zlib
ℹ️

Missing Options.prototype.constructor, BrotliOptions.prototype.constructor, BrotliDecompress.prototype.constructor, ZlibBase.prototype.constructor.

Node.js docs

全域變數

以下是 Deno 支援的 Node 全域變數清單。這些全域變數僅在 npm 套件範圍中可用。在您自己的程式碼中,您可以透過從相關的 node: 模組匯入它們來使用它們。

全域變數名稱狀態
AbortController
AbortSignal
Blob
Buffer
ByteLengthQueuingStrategy
__dirname⚠️ 文件 >
__filename⚠️ 文件 >
atob
BroadcastChannel
btoa
clearImmediate
clearInterval
clearTimeout
CompressionStream
console
CountQueuingStrategy
Crypto
CryptoKey
CustomEvent
CustomEvent
DecompressionStream
Event
EventTarget
exports
fetch
fetch
File
File
FormData
global
Headers
MessageChannel
MessageEvent
MessagePort
module
PerformanceEntry
PerformanceMark
PerformanceMeasure
PerformanceObserver
PerformanceObserverEntryList
PerformanceResourceTiming
performance
process
queueMicrotask
ReadableByteStreamController
ReadableStream
ReadableStreamBYOBReader
ReadableStreamBYOBRequest
ReadableStreamDefaultController
ReadableStreamDefaultReader
require
Response
Request
setImmediate
setInterval
setTimeout
structuredClone
structuredClone
SubtleCrypto
DOMException
TextDecoder
TextDecoderStream
TextEncoder
TextEncoderStream
TransformStream
TransformStreamDefaultController
URL
URLSearchParams
URLSearchParams
WebAssembly
WritableStream
WritableStreamDefaultController
WritableStreamDefaultWriter