Node.js v16.20.2 文档


弃用的 API#>

🌐 Deprecated APIs

Node.js API 可能由于以下任何原因而被弃用:

🌐 Node.js APIs might be deprecated for any of the following reasons:

  • 使用该 API 不安全。
  • 有一个改进的替代 API 可用。
  • 预计在未来的主要版本中,API将会有重大变更。

Node.js 使用了三种弃用:

🌐 Node.js uses three kinds of Deprecations:

  • 仅限文档
  • 运行时
  • 生命终结

仅文档弃用是指仅在 Node.js API 文档中表达的弃用。在运行 Node.js 时,这些不会产生任何副作用。某些仅文档弃用在使用 --pending-deprecation 标志(或其替代的 NODE_PENDING_DEPRECATION=1 环境变量)启动时会触发运行时警告,类似于下面的运行时弃用。支持该标志的仅文档弃用将在已弃用 API 列表中明确标注。

🌐 A Documentation-only deprecation is one that is expressed only within the Node.js API docs. These generate no side-effects while running Node.js. Some Documentation-only deprecations trigger a runtime warning when launched with --pending-deprecation flag (or its alternative, NODE_PENDING_DEPRECATION=1 environment variable), similarly to Runtime deprecations below. Documentation-only deprecations that support that flag are explicitly labeled as such in the list of Deprecated APIs.

运行时弃用默认会生成一个进程警告,该警告会在第一次使用已弃用的 API 时打印到 stderr。当使用 --throw-deprecation 命令行标志时,运行时弃用会导致抛出错误。

🌐 A Runtime deprecation will, by default, generate a process warning that will be printed to stderr the first time the deprecated API is used. When the --throw-deprecation command-line flag is used, a Runtime deprecation will cause an error to be thrown.

当 Node.js 的某项功能正在或即将被移除时,会使用终止支持弃用。

🌐 An End-of-Life deprecation is used when functionality is or will soon be removed from Node.js.

撤销弃用#>

🌐 Revoking deprecations

有时,API 的弃用可能会被撤销。在这种情况下,本文件将会更新与该决策相关的信息。然而,弃用标识符将不会被修改。

🌐 Occasionally, the deprecation of an API might be reversed. In such situations, this document will be updated with information relevant to the decision. However, the deprecation identifier will not be modified.

已弃用的 API 列表#>

🌐 List of deprecated APIs

DEP0001:http.OutgoingMessage.prototype.flush#>

🌐 DEP0001: http.OutgoingMessage.prototype.flush

类型:寿命终止

🌐 Type: End-of-Life

OutgoingMessage.prototype.flush() 已被移除。请改用 OutgoingMessage.prototype.flushHeaders()

DEP0002: require('_linklist')#>

类型:寿命终止

🌐 Type: End-of-Life

_linklist 模块已被弃用。请使用用户空间的替代方案。

🌐 The _linklist module is deprecated. Please use a userland alternative.

DEP0003: _writableState.buffer#>

类型:寿命终止

🌐 Type: End-of-Life

_writableState.buffer 已被移除。请改用 _writableState.getBuffer()

🌐 The _writableState.buffer has been removed. Use _writableState.getBuffer() instead.

DEP0004:CryptoStream.prototype.readyState#>

🌐 DEP0004: CryptoStream.prototype.readyState

类型:寿命终止

🌐 Type: End-of-Life

CryptoStream.prototype.readyState 属性已被移除。

🌐 The CryptoStream.prototype.readyState property was removed.

DEP0005:Buffer() 构造函数#>

🌐 DEP0005: Buffer() constructor

类型:运行时(支持 --pending-deprecation

🌐 Type: Runtime (supports --pending-deprecation)

Buffer() 函数和 new Buffer() 构造函数由于 API 可用性问题而被弃用,这些问题可能导致意外的安全问题。

🌐 The Buffer() function and new Buffer() constructor are deprecated due to API usability issues that can lead to accidental security issues.

作为替代,可以使用以下方法之一来构建 Buffer 对象:

🌐 As an alternative, use one of the following methods of constructing Buffer objects:

如果没有使用 --pending-deprecation,运行时警告只会针对不在 node_modules 中的代码触发。这意味着使用依赖中的 Buffer() 不会产生弃用警告。使用 --pending-deprecation 后,无论 Buffer() 使用在何处,都会产生运行时警告。

🌐 Without --pending-deprecation, runtime warnings occur only for code not in node_modules. This means there will not be deprecation warnings for Buffer() usage in dependencies. With --pending-deprecation, a runtime warning results no matter where the Buffer() usage occurs.

DEP0006:child_process options.customFds#>

🌐 DEP0006: child_process options.customFds

类型:寿命终止

🌐 Type: End-of-Life

child_process 模块的 spawn()fork()exec() 方法中,options.customFds 选项已被弃用。应改用 options.stdio 选项。

🌐 Within the child_process module's spawn(), fork(), and exec() methods, the options.customFds option is deprecated. The options.stdio option should be used instead.

DEP0007:将 cluster 中的 worker.suicide 替换为 worker.exitedAfterDisconnect#>

🌐 DEP0007: Replace cluster worker.suicide with worker.exitedAfterDisconnect

类型:寿命终止

🌐 Type: End-of-Life

在早期版本的 Node.js cluster 中,Worker 对象上添加了一个名为 suicide 的布尔属性。这个属性的目的是提供关于 Worker 实例如何以及为什么退出的指示。在 Node.js 6.0.0 中,旧属性已被弃用,并被一个新的 worker.exitedAfterDisconnect 属性取代。旧属性名并没有准确描述实际语义,而且带有不必要的情感色彩。

🌐 In an earlier version of the Node.js cluster, a boolean property with the name suicide was added to the Worker object. The intent of this property was to provide an indication of how and why the Worker instance exited. In Node.js 6.0.0, the old property was deprecated and replaced with a new worker.exitedAfterDisconnect property. The old property name did not precisely describe the actual semantics and was unnecessarily emotion-laden.

DEP0008:require('node:constants')#>

🌐 DEP0008: require('node:constants')

类型:仅文档

🌐 Type: Documentation-only

node:constants 模块已被弃用。当需要访问与特定 Node.js 内置模块相关的常量时,开发者应改为参考相关模块公开的 constants 属性。例如,require('node:fs').constantsrequire('node:os').constants

🌐 The node:constants module is deprecated. When requiring access to constants relevant to specific Node.js builtin modules, developers should instead refer to the constants property exposed by the relevant module. For instance, require('node:fs').constants and require('node:os').constants.

DEP0009:crypto.pbkdf2 未指定摘要#>

🌐 DEP0009: crypto.pbkdf2 without digest

类型:寿命终止

🌐 Type: End-of-Life

在 Node.js 6.0 中,如果未指定摘要就使用 crypto.pbkdf2() API,则被弃用,因为该方法默认使用不推荐的 'SHA1' 摘要。之前会打印弃用警告。从 Node.js 8.0.0 开始,如果调用 crypto.pbkdf2()crypto.pbkdf2Sync() 时将 digest 设置为 undefined,将会抛出 TypeError

🌐 Use of the crypto.pbkdf2() API without specifying a digest was deprecated in Node.js 6.0 because the method defaulted to using the non-recommended 'SHA1' digest. Previously, a deprecation warning was printed. Starting in Node.js 8.0.0, calling crypto.pbkdf2() or crypto.pbkdf2Sync() with digest set to undefined will throw a TypeError.

从 Node.js v11.0.0 开始,当 digest 设置为 null 调用这些函数时,会打印弃用警告,以与 digestundefined 时的行为保持一致。

🌐 Beginning in Node.js v11.0.0, calling these functions with digest set to null would print a deprecation warning to align with the behavior when digest is undefined.

但是,现在传入 undefinednull 会抛出 TypeError

🌐 Now, however, passing either undefined or null will throw a TypeError.

DEP0010: crypto.createCredentials#>

类型:寿命终止

🌐 Type: End-of-Life

crypto.createCredentials() API 已被移除。请改用 tls.createSecureContext()

🌐 The crypto.createCredentials() API was removed. Please use tls.createSecureContext() instead.

DEP0011:crypto.Credentials#>

🌐 DEP0011: crypto.Credentials

类型:寿命终止

🌐 Type: End-of-Life

crypto.Credentials 类已被移除。请改用 tls.SecureContext

🌐 The crypto.Credentials class was removed. Please use tls.SecureContext instead.

DEP0012: Domain.dispose#>

类型:寿命终止

🌐 Type: End-of-Life

Domain.dispose() 已被移除。请通过在域上设置的错误事件处理程序显式地恢复失败的 I/O 操作。

DEP0013:没有回调的 fs 异步函数#>

🌐 DEP0013: fs asynchronous function without callback

类型:寿命终止

🌐 Type: End-of-Life

在 Node.js 10.0.0 及以后的版本中,如果调用异步函数而不提供回调函数,会抛出 TypeError。详见 https://github.com/nodejs/node/pull/12562

DEP0014:fs.read 旧版字符串接口#>

🌐 DEP0014: fs.read legacy String interface

类型:寿命终止

🌐 Type: End-of-Life

fs.read() 继承的 String 接口已被弃用。请改用文档中提到的 Buffer API。

🌐 The fs.read() legacy String interface is deprecated. Use the Buffer API as mentioned in the documentation instead.

DEP0015:fs.readSync 过时的字符串接口#>

🌐 DEP0015: fs.readSync legacy String interface

类型:寿命终止

🌐 Type: End-of-Life

fs.readSync() 旧版的 String 接口已被弃用。请改用文档中提到的 Buffer API。

🌐 The fs.readSync() legacy String interface is deprecated. Use the Buffer API as mentioned in the documentation instead.

DEP0016: GLOBAL/root#>

类型:寿命终止

🌐 Type: End-of-Life

global 属性的 GLOBALroot 别名在 Node.js 6.0.0 中已被弃用,并已被移除。

🌐 The GLOBAL and root aliases for the global property were deprecated in Node.js 6.0.0 and have since been removed.

DEP0017: Intl.v8BreakIterator#>

类型:寿命终止

🌐 Type: End-of-Life

Intl.v8BreakIterator 是一个非标准扩展,已经被移除。 请参阅 Intl.Segmenter

DEP0018:未处理的 Promise 拒绝#>

🌐 DEP0018: Unhandled promise rejections

类型:寿命终止

🌐 Type: End-of-Life

未处理的 Promise 拒绝已被弃用。默认情况下,未处理的 Promise 拒绝会使 Node.js 进程以非零退出码终止。要更改 Node.js 对未处理拒绝的处理方式,请使用 --unhandled-rejections 命令行选项。

🌐 Unhandled promise rejections are deprecated. By default, promise rejections that are not handled terminate the Node.js process with a non-zero exit code. To change the way Node.js treats unhandled rejections, use the --unhandled-rejections command-line option.

DEP0019:require('.') 在目录外被解析#>

🌐 DEP0019: require('.') resolved outside directory

类型:寿命终止

🌐 Type: End-of-Life

在某些情况下,require('.') 可能会解析到包目录之外。此行为已被移除。

🌐 In certain cases, require('.') could resolve outside the package directory. This behavior has been removed.

DEP0020:Server.connections#>

🌐 DEP0020: Server.connections

类型:寿命终止

🌐 Type: End-of-Life

Server.connections 属性在 Node.js v0.9.7 中已被弃用,并且已被移除。请改用 Server.getConnections() 方法。

🌐 The Server.connections property was deprecated in Node.js v0.9.7 and has been removed. Please use the Server.getConnections() method instead.

DEP0021:Server.listenFD#>

🌐 DEP0021: Server.listenFD

类型:寿命终止

🌐 Type: End-of-Life

Server.listenFD() 方法已被弃用并移除。请改用 [Server.listen({fd:<number>})][Server.listen({fd:<number>})]。

DEP0022: os.tmpDir()#>

类型:寿命终止

🌐 Type: End-of-Life

os.tmpDir() API 在 Node.js 7.0.0 中已被废弃,并且之后已被移除。请改用 os.tmpdir()

🌐 The os.tmpDir() API was deprecated in Node.js 7.0.0 and has since been removed. Please use os.tmpdir() instead.

DEP0023: os.getNetworkInterfaces()#>

类型:寿命终止

🌐 Type: End-of-Life

os.getNetworkInterfaces() 方法已被弃用。请改用 os.networkInterfaces() 方法。

🌐 The os.getNetworkInterfaces() method is deprecated. Please use the os.networkInterfaces() method instead.

DEP0024: REPLServer.prototype.convertToContext()#>

类型:寿命终止

🌐 Type: End-of-Life

REPLServer.prototype.convertToContext() API 已被移除。

🌐 The REPLServer.prototype.convertToContext() API has been removed.

DEP0025:require('node:sys')#>

🌐 DEP0025: require('node:sys')

类型:运行时

🌐 Type: Runtime

node:sys 模块已被弃用。请改用 util 模块。

🌐 The node:sys module is deprecated. Please use the util module instead.

DEP0026: util.print()#>

类型:寿命终止

🌐 Type: End-of-Life

util.print() 已被移除。请使用 console.log() 代替。

DEP0027: util.puts()#>

类型:寿命终止

🌐 Type: End-of-Life

util.puts() 已被移除。请改用 console.log()

DEP0028: util.debug()#>

类型:寿命终止

🌐 Type: End-of-Life

util.debug() 已被移除。请使用 console.error() 代替。

DEP0029: util.error()#>

类型:寿命终止

🌐 Type: End-of-Life

util.error() 已被移除。请使用 console.error() 代替。

DEP0030:SlowBuffer#>

🌐 DEP0030: SlowBuffer

类型:仅文档

🌐 Type: Documentation-only

SlowBuffer 类已被弃用。请改用 Buffer.allocUnsafeSlow(size)

🌐 The SlowBuffer class is deprecated. Please use Buffer.allocUnsafeSlow(size) instead.

DEP0031: ecdh.setPublicKey()#>

类型:仅文档

🌐 Type: Documentation-only

ecdh.setPublicKey() 方法现在已被弃用,因为在 API 中包含它没有用处。

🌐 The ecdh.setPublicKey() method is now deprecated as its inclusion in the API is not useful.

DEP0032: node:domain 模块#>

🌐 DEP0032: node:domain module

类型:仅文档

🌐 Type: Documentation-only

domain 模块已弃用,不应使用。

🌐 The domain module is deprecated and should not be used.

DEP0033: EventEmitter.listenerCount()#>

类型:仅文档

🌐 Type: Documentation-only

events.listenerCount(emitter, eventName) API 已被弃用。请改用 emitter.listenerCount(eventName)

🌐 The events.listenerCount(emitter, eventName) API is deprecated. Please use emitter.listenerCount(eventName) instead.

DEP0034: fs.exists(path, callback)#>

类型:仅文档

🌐 Type: Documentation-only

fs.exists(path, callback) API 已被弃用。请改用 fs.stat()fs.access()

🌐 The fs.exists(path, callback) API is deprecated. Please use fs.stat() or fs.access() instead.

DEP0035:fs.lchmod(路径, 模式, 回调)#>

🌐 DEP0035: fs.lchmod(path, mode, callback)

类型:仅文档

🌐 Type: Documentation-only

fs.lchmod(path, mode, callback) API 已被弃用。

🌐 The fs.lchmod(path, mode, callback) API is deprecated.

DEP0036: fs.lchmodSync(路径, 模式)#>

🌐 DEP0036: fs.lchmodSync(path, mode)

类型:仅文档

🌐 Type: Documentation-only

fs.lchmodSync(path, mode) API 已被弃用。

🌐 The fs.lchmodSync(path, mode) API is deprecated.

DEP0037:fs.lchown(path, uid, gid, callback)#>

🌐 DEP0037: fs.lchown(path, uid, gid, callback)

类型:弃用已撤销

🌐 Type: Deprecation revoked

fs.lchown(path, uid, gid, callback) API 已被弃用。由于 libuv 中添加了所需的支持 API,该弃用已被撤销。

🌐 The fs.lchown(path, uid, gid, callback) API was deprecated. The deprecation was revoked because the requisite supporting APIs were added in libuv.

DEP0038: fs.lchownSync(path, uid, gid)#>

类型:弃用已撤销

🌐 Type: Deprecation revoked

fs.lchownSync(path, uid, gid) API 已被弃用。由于 libuv 中添加了所需的支持 API,该弃用已被撤销。

🌐 The fs.lchownSync(path, uid, gid) API was deprecated. The deprecation was revoked because the requisite supporting APIs were added in libuv.

DEP0039: require.extensions#>

类型:仅文档

🌐 Type: Documentation-only

require.extensions 属性已弃用。

🌐 The require.extensions property is deprecated.

DEP0040:node:punycode 模块#>

🌐 DEP0040: node:punycode module

类型:仅文档(支持 --pending-deprecation

🌐 Type: Documentation-only (supports --pending-deprecation)

punycode 模块已被弃用。请改用用户空间的替代方案。

🌐 The punycode module is deprecated. Please use a userland alternative instead.

DEP0041:NODE_REPL_HISTORY_FILE 环境变量#>

🌐 DEP0041: NODE_REPL_HISTORY_FILE environment variable

类型:寿命终止

🌐 Type: End-of-Life

NODE_REPL_HISTORY_FILE 环境变量已被移除。请改用 NODE_REPL_HISTORY

🌐 The NODE_REPL_HISTORY_FILE environment variable was removed. Please use NODE_REPL_HISTORY instead.

DEP0042: tls.CryptoStream#>

类型:寿命终止

🌐 Type: End-of-Life

tls.CryptoStream 类已被移除。请改用 tls.TLSSocket

🌐 The tls.CryptoStream class was removed. Please use tls.TLSSocket instead.

DEP0043: tls.SecurePair#>

类型:仅文档

🌐 Type: Documentation-only

tls.SecurePair 类已被弃用。请改用 tls.TLSSocket

🌐 The tls.SecurePair class is deprecated. Please use tls.TLSSocket instead.

DEP0044:util.isArray()#>

🌐 DEP0044: util.isArray()

类型:仅文档

🌐 Type: Documentation-only

util.isArray() API 已被弃用。请改用 Array.isArray()

🌐 The util.isArray() API is deprecated. Please use Array.isArray() instead.

DEP0045:util.isBoolean()#>

🌐 DEP0045: util.isBoolean()

类型:仅文档

🌐 Type: Documentation-only

util.isBoolean() API 已被弃用。

🌐 The util.isBoolean() API is deprecated.

DEP0046: util.isBuffer()#>

类型:仅文档

🌐 Type: Documentation-only

util.isBuffer() API 已被弃用。请改用 Buffer.isBuffer()

🌐 The util.isBuffer() API is deprecated. Please use Buffer.isBuffer() instead.

DEP0047: util.isDate()#>

类型:仅文档

🌐 Type: Documentation-only

util.isDate() API 已被弃用。

🌐 The util.isDate() API is deprecated.

DEP0048: util.isError()#>

类型:仅文档

🌐 Type: Documentation-only

util.isError() API 已被弃用。

🌐 The util.isError() API is deprecated.

DEP0049: util.isFunction()#>

类型:仅文档

🌐 Type: Documentation-only

util.isFunction() API 已被弃用。

🌐 The util.isFunction() API is deprecated.

DEP0050: util.isNull()#>

类型:仅文档

🌐 Type: Documentation-only

util.isNull() API 已被弃用。

🌐 The util.isNull() API is deprecated.

DEP0051: util.isNullOrUndefined()#>

类型:仅文档

🌐 Type: Documentation-only

util.isNullOrUndefined() API 已被弃用。

🌐 The util.isNullOrUndefined() API is deprecated.

DEP0052: util.isNumber()#>

类型:仅文档

🌐 Type: Documentation-only

util.isNumber() API 已被弃用。

🌐 The util.isNumber() API is deprecated.

DEP0053:util.isObject()#>

🌐 DEP0053: util.isObject()

类型:仅文档

🌐 Type: Documentation-only

util.isObject() API 已被弃用。

🌐 The util.isObject() API is deprecated.

DEP0054: util.isPrimitive()#>

类型:仅文档

🌐 Type: Documentation-only

util.isPrimitive() API 已被弃用。

🌐 The util.isPrimitive() API is deprecated.

DEP0055: util.isRegExp()#>

类型:仅文档

🌐 Type: Documentation-only

util.isRegExp() API 已被弃用。

🌐 The util.isRegExp() API is deprecated.

DEP0056: util.isString()#>

类型:仅文档

🌐 Type: Documentation-only

util.isString() API 已被弃用。

🌐 The util.isString() API is deprecated.

DEP0057: util.isSymbol()#>

类型:仅文档

🌐 Type: Documentation-only

util.isSymbol() API 已被弃用。

🌐 The util.isSymbol() API is deprecated.

DEP0058:util.isUndefined()#>

🌐 DEP0058: util.isUndefined()

类型:仅文档

🌐 Type: Documentation-only

util.isUndefined() API 已被弃用。

🌐 The util.isUndefined() API is deprecated.

DEP0059: util.log()#>

类型:仅文档

🌐 Type: Documentation-only

util.log() API 已被弃用。

🌐 The util.log() API is deprecated.

DEP0060: util._extend()#>

类型:仅文档

🌐 Type: Documentation-only

util._extend() API 已被弃用。

🌐 The util._extend() API is deprecated.

DEP0061: fs.SyncWriteStream#>

类型:寿命终止

🌐 Type: End-of-Life

fs.SyncWriteStream 类从未打算作为公开可访问的 API,并且已被移除。目前没有可用的替代 API。请使用用户空间的替代方案。

🌐 The fs.SyncWriteStream class was never intended to be a publicly accessible API and has been removed. No alternative API is available. Please use a userland alternative.

DEP0062: node --debug#>

类型:寿命终止

🌐 Type: End-of-Life

--debug 启用的是已被废弃的 V8 调试器接口,自 V8 5.8 起已被移除。它已被 Inspector 所取代,可通过 --inspect 来启用。

DEP0063: ServerResponse.prototype.writeHeader()#>

类型:仅文档

🌐 Type: Documentation-only

node:http 模块的 ServerResponse.prototype.writeHeader() API 已被弃用。请改用 ServerResponse.prototype.writeHead()

🌐 The node:http module ServerResponse.prototype.writeHeader() API is deprecated. Please use ServerResponse.prototype.writeHead() instead.

ServerResponse.prototype.writeHeader() 方法从未被记录为官方支持的 API。

🌐 The ServerResponse.prototype.writeHeader() method was never documented as an officially supported API.

DEP0064: tls.createSecurePair()#>

类型:运行时

🌐 Type: Runtime

在 Node.js 0.11.3 的文档中,tls.createSecurePair() API 已被弃用。用户应改用 tls.Socket

🌐 The tls.createSecurePair() API was deprecated in documentation in Node.js 0.11.3. Users should use tls.Socket instead.

DEP0065:repl.REPL_MODE_MAGICNODE_REPL_MODE=magic#>

🌐 DEP0065: repl.REPL_MODE_MAGIC and NODE_REPL_MODE=magic

类型:寿命终止

🌐 Type: End-of-Life

node:repl 模块的 REPL_MODE_MAGIC 常量(用于 replMode 选项)已被移除。自 Node.js 6.0.0 引入 V8 5.0 以来,其行为与 REPL_MODE_SLOPPY 功能上相同。请改用 REPL_MODE_SLOPPY

🌐 The node:repl module's REPL_MODE_MAGIC constant, used for replMode option, has been removed. Its behavior has been functionally identical to that of REPL_MODE_SLOPPY since Node.js 6.0.0, when V8 5.0 was imported. Please use REPL_MODE_SLOPPY instead.

NODE_REPL_MODE 环境变量用于设置交互式 node 会话的底层 replMode。其值 magic 也已被移除。请改用 sloppy

🌐 The NODE_REPL_MODE environment variable is used to set the underlying replMode of an interactive node session. Its value, magic, is also removed. Please use sloppy instead.

DEP0066:OutgoingMessage.prototype._headers, OutgoingMessage.prototype._headerNames#>

🌐 DEP0066: OutgoingMessage.prototype._headers, OutgoingMessage.prototype._headerNames

类型:运行时

🌐 Type: Runtime

node:http 模块的 OutgoingMessage.prototype._headersOutgoingMessage.prototype._headerNames 属性已被弃用。请使用其中一个公共方法(例如 OutgoingMessage.prototype.getHeader()OutgoingMessage.prototype.getHeaders()OutgoingMessage.prototype.getHeaderNames()OutgoingMessage.prototype.getRawHeaderNames()OutgoingMessage.prototype.hasHeader()OutgoingMessage.prototype.removeHeader()OutgoingMessage.prototype.setHeader())来处理发送的头信息。

🌐 The node:http module OutgoingMessage.prototype._headers and OutgoingMessage.prototype._headerNames properties are deprecated. Use one of the public methods (e.g. OutgoingMessage.prototype.getHeader(), OutgoingMessage.prototype.getHeaders(), OutgoingMessage.prototype.getHeaderNames(), OutgoingMessage.prototype.getRawHeaderNames(), OutgoingMessage.prototype.hasHeader(), OutgoingMessage.prototype.removeHeader(), OutgoingMessage.prototype.setHeader()) for working with outgoing headers.

OutgoingMessage.prototype._headersOutgoingMessage.prototype._headerNames 属性从未被记录为官方支持的属性。

🌐 The OutgoingMessage.prototype._headers and OutgoingMessage.prototype._headerNames properties were never documented as officially supported properties.

DEP0067:OutgoingMessage.prototype._renderHeaders#>

🌐 DEP0067: OutgoingMessage.prototype._renderHeaders

类型:仅文档

🌐 Type: Documentation-only

node:http 模块的 OutgoingMessage.prototype._renderHeaders() API 已被弃用。

🌐 The node:http module OutgoingMessage.prototype._renderHeaders() API is deprecated.

OutgoingMessage.prototype._renderHeaders 属性从未被记录为官方支持的 API。

🌐 The OutgoingMessage.prototype._renderHeaders property was never documented as an officially supported API.

DEP0068: node debug#>

类型:寿命终止

🌐 Type: End-of-Life

node debug 对应于旧版命令行调试器,该调试器已被基于 V8 检查器的命令行调试器替代,可通过 node inspect 使用。

DEP0069:vm.runInDebugContext(string)#>

🌐 DEP0069: vm.runInDebugContext(string)

类型:寿命终止

🌐 Type: End-of-Life

DebugContext 已在 V8 中删除,在 Node.js 10+ 中不可用。

🌐 DebugContext has been removed in V8 and is not available in Node.js 10+.

DebugContext 是一个实验性 API。

🌐 DebugContext was an experimental API.

DEP0070: async_hooks.currentId()#>

类型:寿命终止

🌐 Type: End-of-Life

async_hooks.currentId() 为了更清晰的表达被重命名为 async_hooks.executionAsyncId()

此更改是在 async_hooks 作为实验性 API 时进行的。

🌐 This change was made while async_hooks was an experimental API.

DEP0071: async_hooks.triggerId()#>

类型:寿命终止

🌐 Type: End-of-Life

async_hooks.triggerId() 为了更清楚的表达被重命名为 async_hooks.triggerAsyncId()

此更改是在 async_hooks 作为实验性 API 时进行的。

🌐 This change was made while async_hooks was an experimental API.

DEP0072:async_hooks.AsyncResource.triggerId()#>

🌐 DEP0072: async_hooks.AsyncResource.triggerId()

类型:寿命终止

🌐 Type: End-of-Life

async_hooks.AsyncResource.triggerId() 已被重命名为 async_hooks.AsyncResource.triggerAsyncId() 以提高清晰度。

此更改是在 async_hooks 作为实验性 API 时进行的。

🌐 This change was made while async_hooks was an experimental API.

DEP0073:net.Server 的几个内部属性#>

🌐 DEP0073: Several internal properties of net.Server

类型:寿命终止

🌐 Type: End-of-Life

访问 net.Server 实例的多个内部、未文档化属性且使用不当名称已被弃用。

🌐 Accessing several internal, undocumented properties of net.Server instances with inappropriate names is deprecated.

由于原始 API 没有文档说明,并且对非内部代码通常没有用处,因此没有提供替代 API。

🌐 As the original API was undocumented and not generally useful for non-internal code, no replacement API is provided.

DEP0074:REPLServer.bufferedCommand#>

🌐 DEP0074: REPLServer.bufferedCommand

类型:寿命终止

🌐 Type: End-of-Life

REPLServer.bufferedCommand 属性已被弃用,建议使用 REPLServer.clearBufferedCommand()

🌐 The REPLServer.bufferedCommand property was deprecated in favor of REPLServer.clearBufferedCommand().

DEP0075: REPLServer.parseREPLKeyword()#>

类型:寿命终止

🌐 Type: End-of-Life

REPLServer.parseREPLKeyword() 已从用户可见范围中移除。

DEP0076: tls.parseCertString()#>

类型:运行时

🌐 Type: Runtime

tls.parseCertString() 是一个微不足道的解析辅助函数,被错误地公开了。通常可以用以下方法替代这个函数:

const querystring = require('querystring');
querystring.parse(str, '\n', '='); 

这个函数并不完全等同于 querystring.parse()。一个区别是 querystring.parse() 会进行 URL 解码:

🌐 This function is not completely equivalent to querystring.parse(). One difference is that querystring.parse() does url decoding:

> querystring.parse('%E5%A5%BD=1', '\n', '=');
{ '好': '1' }
> tls.parseCertString('%E5%A5%BD=1');
{ '%E5%A5%BD': '1' } 

DEP0077: Module._debug()#>

类型:运行时

🌐 Type: Runtime

Module._debug() 已被弃用。

Module._debug() 函数从未被记录为官方支持的 API。

🌐 The Module._debug() function was never documented as an officially supported API.

DEP0078: REPLServer.turnOffEditorMode()#>

类型:寿命终止

🌐 Type: End-of-Life

REPLServer.turnOffEditorMode() 已从用户可见性中移除。

DEP0079:通过 .inspect() 对对象进行自定义检查函数#>

🌐 DEP0079: Custom inspection function on objects via .inspect()

类型:寿命终止

🌐 Type: End-of-Life

在对象上使用名为 inspect 的属性来为 util.inspect() 指定自定义检查函数已被弃用。请改用 util.inspect.custom。为了与 6.4.0 版本之前的 Node.js 向后兼容,可以同时指定两者。

🌐 Using a property named inspect on an object to specify a custom inspection function for util.inspect() is deprecated. Use util.inspect.custom instead. For backward compatibility with Node.js prior to version 6.4.0, both can be specified.

DEP0080: path._makeLong()#>

类型:仅文档

🌐 Type: Documentation-only

内部的 path._makeLong() 并非面向公共使用。然而,用户层模块发现它很有用。该内部 API 已被废弃,并由一个相同的公共方法 path.toNamespacedPath() 所取代。

🌐 The internal path._makeLong() was not intended for public use. However, userland modules have found it useful. The internal API is deprecated and replaced with an identical, public path.toNamespacedPath() method.

DEP0081:使用文件描述符的 fs.truncate()#>

🌐 DEP0081: fs.truncate() using a file descriptor

类型:运行时

🌐 Type: Runtime

使用文件描述符的 fs.truncate()fs.truncateSync() 已被弃用。请使用 fs.ftruncate()fs.ftruncateSync() 来处理文件描述符。

DEP0082: REPLServer.prototype.memory()#>

类型:寿命终止

🌐 Type: End-of-Life

REPLServer.prototype.memory() 仅对 REPLServer 本身的内部机制是必要的。不要使用此函数。

DEP0083:通过将 ecdhCurve 设置为 false 来禁用 ECDH#>

🌐 DEP0083: Disabling ECDH by setting ecdhCurve to false

类型:已终止服务。

🌐 Type: End-of-Life.

tls.createSecureContext()tls.TLSSocketecdhCurve 选项可以设置为 false,以仅在服务器上完全禁用 ECDH。此模式已被弃用,以便为迁移到 OpenSSL 1.1.0 并与客户端保持一致做准备,并且现在已不再支持。请改用 ciphers 参数。

🌐 The ecdhCurve option to tls.createSecureContext() and tls.TLSSocket could be set to false to disable ECDH entirely on the server only. This mode was deprecated in preparation for migrating to OpenSSL 1.1.0 and consistency with the client and is now unsupported. Use the ciphers parameter instead.

DEP0084:需要打包的内部依赖#>

🌐 DEP0084: requiring bundled internal dependencies

类型:寿命终止

🌐 Type: End-of-Life

自 Node.js 版本 4.4.0 和 5.2.0 起,一些仅用于内部的模块被错误地通过 require() 暴露给用户代码。这些模块包括:

🌐 Since Node.js versions 4.4.0 and 5.2.0, several modules only intended for internal usage were mistakenly exposed to user code through require(). These modules were:

  • v8/tools/codemap
  • v8/tools/consarray
  • v8/tools/csvparser
  • v8/tools/logreader
  • v8/tools/profile_view
  • v8/tools/profile
  • v8/tools/SourceMap
  • v8/tools/splaytree
  • v8/tools/tickprocessor-driver
  • v8/tools/tickprocessor
  • node-inspect/lib/_inspect(来自 7.6.0)
  • node-inspect/lib/internal/inspect_client(从 7.6.0 开始)
  • node-inspect/lib/internal/inspect_repl(来自 7.6.0)

v8/* 模块没有任何导出,如果不按特定顺序导入,实际上会抛出错误。因此,几乎没有合法的使用场景通过 require() 导入它们。

🌐 The v8/* modules do not have any exports, and if not imported in a specific order would in fact throw errors. As such there are virtually no legitimate use cases for importing them through require().

另一方面,node-inspect 可以通过包管理器在本地安装,因为它以相同的名称发布在 npm 注册表上。如果这样做,就不需要修改源代码。

🌐 On the other hand, node-inspect can be installed locally through a package manager, as it is published on the npm registry under the same name. No source code modification is necessary if that is done.

DEP0085:AsyncHooks 敏感 API#>

🌐 DEP0085: AsyncHooks sensitive API

类型:寿命终止

🌐 Type: End-of-Life

AsyncHooks 敏感 API 从未被记录,并且存在各种小问题。请使用 AsyncResource API 替代。详见 https://github.com/nodejs/node/issues/15572

DEP0086:移除 runInAsyncIdScope#>

🌐 DEP0086: Remove runInAsyncIdScope

类型:寿命终止

🌐 Type: End-of-Life

runInAsyncIdScope 不会触发 'before''after' 事件,因此可能会引发许多问题。详见 https://github.com/nodejs/node/issues/14328

DEP0089:require('node:assert')#>

🌐 DEP0089: require('node:assert')

类型:弃用已撤销

🌐 Type: Deprecation revoked

不推荐直接导入 assert,因为暴露的函数使用的是宽松的相等检查。废弃声明已被撤销,因为并不禁止使用 node:assert 模块,而且废弃声明导致了开发者的困惑。

🌐 Importing assert directly was not recommended as the exposed functions use loose equality checks. The deprecation was revoked because use of the node:assert module is not discouraged, and the deprecation caused developer confusion.

DEP0090:无效的 GCM 认证标签长度#>

🌐 DEP0090: Invalid GCM authentication tag lengths

类型:寿命终止

🌐 Type: End-of-Life

Node.js 过去支持所有在调用 decipher.setAuthTag() 时被 OpenSSL 接受的 GCM 认证标签长度。从 Node.js v11.0.0 开始,仅允许 128、120、112、104、96、64 和 32 位的认证标签。其他长度的认证标签根据 NIST SP 800-38D 是无效的。

🌐 Node.js used to support all GCM authentication tag lengths which are accepted by OpenSSL when calling decipher.setAuthTag(). Beginning with Node.js v11.0.0, only authentication tag lengths of 128, 120, 112, 104, 96, 64, and 32 bits are allowed. Authentication tags of other lengths are invalid per NIST SP 800-38D.

DEP0091:crypto.DEFAULT_ENCODING#>

🌐 DEP0091: crypto.DEFAULT_ENCODING

类型:运行时

🌐 Type: Runtime

crypto.DEFAULT_ENCODING 属性已弃用。

🌐 The crypto.DEFAULT_ENCODING property is deprecated.

DEP0092:顶层 this 绑定到 module.exports#>

🌐 DEP0092: Top-level this bound to module.exports

类型:仅文档

🌐 Type: Documentation-only

将属性分配给顶层 this 作为 module.exports 的替代方法已被弃用。开发者应使用 exportsmodule.exports

🌐 Assigning properties to the top-level this as an alternative to module.exports is deprecated. Developers should use exports or module.exports instead.

DEP0093:crypto.fips 已被弃用并被替代#>

🌐 DEP0093: crypto.fips is deprecated and replaced

类型:仅文档

🌐 Type: Documentation-only

crypto.fips 属性已弃用。请改用 crypto.setFips()crypto.getFips()

🌐 The crypto.fips property is deprecated. Please use crypto.setFips() and crypto.getFips() instead.

DEP0094:使用 assert.fail() 时传入多个参数#>

🌐 DEP0094: Using assert.fail() with more than one argument

类型:运行时

🌐 Type: Runtime

使用带有多个参数的 assert.fail() 已被弃用。请使用仅带一个参数的 assert.fail() 或使用其他 node:assert 模块方法。

🌐 Using assert.fail() with more than one argument is deprecated. Use assert.fail() with only one argument or use a different node:assert module method.

DEP0095: timers.enroll()#>

类型:运行时

🌐 Type: Runtime

timers.enroll() 已被弃用。请改用公开文档中介绍的 setTimeout()setInterval()

DEP0096: timers.unenroll()#>

类型:运行时

🌐 Type: Runtime

timers.unenroll() 已弃用。请改用公开文档中介绍的 clearTimeout()clearInterval()

DEP0097:带有 domain 属性的 MakeCallback#>

🌐 DEP0097: MakeCallback with domain property

类型:运行时

🌐 Type: Runtime

使用 MakeCallback 并添加 domain 属性以携带上下文的用户,应开始使用 MakeCallbackasync_context 版本或 CallbackScope,或者使用高级的 AsyncResource 类。

🌐 Users of MakeCallback that add the domain property to carry context, should start using the async_context variant of MakeCallback or CallbackScope, or the high-level AsyncResource class.

DEP0098:AsyncHooks 嵌入器 AsyncResource.emitBeforeAsyncResource.emitAfter API#>

🌐 DEP0098: AsyncHooks embedder AsyncResource.emitBefore and AsyncResource.emitAfter APIs

类型:寿命终止

🌐 Type: End-of-Life

AsyncHooks 提供的嵌入式 API 暴露了 .emitBefore().emitAfter() 方法,这些方法很容易被错误使用,可能导致无法恢复的错误。

🌐 The embedded API provided by AsyncHooks exposes .emitBefore() and .emitAfter() methods which are very easy to use incorrectly which can lead to unrecoverable errors.

请改用 asyncResource.runInAsyncScope() API,它提供了更安全、更方便的替代方案。详见 https://github.com/nodejs/node/pull/18513

DEP0099:异步上下文不感知的 node::MakeCallback C++ API#>

🌐 DEP0099: Async context-unaware node::MakeCallback C++ APIs

类型:编译时

🌐 Type: Compile-time

某些提供给本地插件的 node::MakeCallback API 版本已被弃用。请使用接受 async_context 参数的 API 版本。

🌐 Certain versions of node::MakeCallback APIs available to native addons are deprecated. Please use the versions of the API that accept an async_context parameter.

DEP0100: process.assert()#>

类型:运行时

🌐 Type: Runtime

process.assert() 已被弃用。请改用 assert 模块。

这从来都不是记录在案的功能。

🌐 This was never a documented feature.

DEP0101: --with-lttng#>

类型:寿命终止

🌐 Type: End-of-Life

--with-lttng 编译时选项已被移除。

🌐 The --with-lttng compile-time option has been removed.

DEP0102:在 Buffer#(read|write) 操作中使用 noAssert#>

🌐 DEP0102: Using noAssert in Buffer#(read|write) operations

类型:寿命终止

🌐 Type: End-of-Life

使用 noAssert 参数现在已经没有任何功能了。无论 noAssert 的值如何,所有输入都会被验证。跳过验证可能会导致难以发现的错误和崩溃。

🌐 Using the noAssert argument has no functionality anymore. All input is verified regardless of the value of noAssert. Skipping the verification could lead to hard-to-find errors and crashes.

DEP0103:process.binding('util').is[...] 类型检查#>

🌐 DEP0103: process.binding('util').is[...] typechecks

类型:仅文档(支持 --pending-deprecation

🌐 Type: Documentation-only (supports --pending-deprecation)

一般应避免使用 process.binding()。特别是类型检查方法,可以使用 util.types 来替代。

🌐 Using process.binding() in general should be avoided. The type checking methods in particular can be replaced by using util.types.

此弃用已被 process.binding() API 的弃用所取代 (DEP0111)。

🌐 This deprecation has been superseded by the deprecation of the process.binding() API (DEP0111).

DEP0104:process.env 字符串强制转换#>

🌐 DEP0104: process.env string coercion

类型:仅文档(支持 --pending-deprecation

🌐 Type: Documentation-only (supports --pending-deprecation)

当将非字符串属性赋值给 process.env 时,赋的值会被隐式转换为字符串。如果赋值的不是字符串、布尔值或数字,这种行为已被弃用。将来,此类赋值可能会导致抛出错误。请在将属性赋值给 process.env 之前先将其转换为字符串。

🌐 When assigning a non-string property to process.env, the assigned value is implicitly converted to a string. This behavior is deprecated if the assigned value is not a string, boolean, or number. In the future, such assignment might result in a thrown error. Please convert the property to a string before assigning it to process.env.

DEP0105: decipher.finaltol#>

类型:寿命终止

🌐 Type: End-of-Life

decipher.finaltol() 从未有过文档记录,并且曾是 decipher.final() 的别名。该 API 已被移除,建议改用 decipher.final()

DEP0106: crypto.createCiphercrypto.createDecipher#>

🌐 DEP0106: crypto.createCipher and crypto.createDecipher

类型:运行时

🌐 Type: Runtime

必须避免使用 crypto.createCipher()crypto.createDecipher(),因为它们使用弱密钥派生函数(无盐的 MD5)和静态初始化向量。建议使用 crypto.pbkdf2()crypto.scrypt() 结合随机盐生成密钥,并使用 crypto.createCipheriv()crypto.createDecipheriv() 分别获取 CipherDecipher 对象。

🌐 Using crypto.createCipher() and crypto.createDecipher() must be avoided as they use a weak key derivation function (MD5 with no salt) and static initialization vectors. It is recommended to derive a key using crypto.pbkdf2() or crypto.scrypt() with random salts and to use crypto.createCipheriv() and crypto.createDecipheriv() to obtain the Cipher and Decipher objects respectively.

DEP0107: tls.convertNPNProtocols()#>

类型:寿命终止

🌐 Type: End-of-Life

这是一个未记录的辅助函数,原本不打算在 Node.js 核心之外使用,并且由于 NPN(下一协议协商)支持的移除而被弃用。

🌐 This was an undocumented helper function not intended for use outside Node.js core and obsoleted by the removal of NPN (Next Protocol Negotiation) support.

DEP0108: zlib.bytesRead#>

类型:运行时

🌐 Type: Runtime

zlib.bytesWritten 的已弃用别名。这个原始名称之所以被选择,是因为将该值解释为引擎读取的字节数也有意义,但它与 Node.js 中其他以这些名称公开值的流不一致。

🌐 Deprecated alias for zlib.bytesWritten. This original name was chosen because it also made sense to interpret the value as the number of bytes read by the engine, but is inconsistent with other streams in Node.js that expose values under these names.

DEP0109:对无效 URL 的 httphttpstls 支持#>

🌐 DEP0109: http, https, and tls support for invalid URLs

类型:寿命终止

🌐 Type: End-of-Life

以前一些曾被支持过(但严格来说无效的)URL 可以通过 http.request()http.get()https.request()https.get()tls.checkServerIdentity() API 被接受,这是因为这些 URL 在旧版的 url.parse() API 中是被接受的。上述 API 现在使用要求严格有效 URL 的 WHATWG URL 解析器。传递无效 URL 已被弃用,未来将取消支持。

🌐 Some previously supported (but strictly invalid) URLs were accepted through the http.request(), http.get(), https.request(), https.get(), and tls.checkServerIdentity() APIs because those were accepted by the legacy url.parse() API. The mentioned APIs now use the WHATWG URL parser that requires strictly valid URLs. Passing an invalid URL is deprecated and support will be removed in the future.

DEP0110:vm.Script 缓存数据#>

🌐 DEP0110: vm.Script cached data

类型:仅文档

🌐 Type: Documentation-only

produceCachedData 选项已被弃用。请改用 script.createCachedData()

🌐 The produceCachedData option is deprecated. Use script.createCachedData() instead.

DEP0111: process.binding()#>

类型:仅文档(支持 --pending-deprecation

🌐 Type: Documentation-only (supports --pending-deprecation)

process.binding() 仅供 Node.js 内部代码使用。

虽然 process.binding() 尚未达到生命周期结束状态,但在启用 政策 时不可用。

🌐 While process.binding() has not reached End-of-Life status in general, it is unavailable when policies are enabled.

DEP0112: dgram 私有 API#>

🌐 DEP0112: dgram private APIs

类型:运行时

🌐 Type: Runtime

node:dgram 模块以前包含一些从未打算在 Node.js 核心之外访问的 API:Socket.prototype._handleSocket.prototype._receivingSocket.prototype._bindStateSocket.prototype._queueSocket.prototype._reuseAddrSocket.prototype._healthCheck()Socket.prototype._stopReceiving()dgram._createSocketHandle()

🌐 The node:dgram module previously contained several APIs that were never meant to accessed outside of Node.js core: Socket.prototype._handle, Socket.prototype._receiving, Socket.prototype._bindState, Socket.prototype._queue, Socket.prototype._reuseAddr, Socket.prototype._healthCheck(), Socket.prototype._stopReceiving(), and dgram._createSocketHandle().

DEP0113:Cipher.setAuthTag()Decipher.getAuthTag()#>

🌐 DEP0113: Cipher.setAuthTag(), Decipher.getAuthTag()

类型:寿命终止

🌐 Type: End-of-Life

Cipher.setAuthTag()Decipher.getAuthTag() 不再可用。它们从未被记录过,并且在调用时会抛出异常。

DEP0114: crypto._toBuf()#>

类型:寿命终止

🌐 Type: End-of-Life

crypto._toBuf() 函数并不是为 Node.js 核心之外的模块设计的,并且已经被删除。

🌐 The crypto._toBuf() function was not designed to be used by modules outside of Node.js core and was removed.

DEP0115:crypto.prng()crypto.pseudoRandomBytes()crypto.rng()#>

🌐 DEP0115: crypto.prng(), crypto.pseudoRandomBytes(), crypto.rng()

类型:仅文档(支持 --pending-deprecation

🌐 Type: Documentation-only (supports --pending-deprecation)

在最近版本的 Node.js 中,crypto.randomBytes()crypto.pseudoRandomBytes() 没有区别。后者已被弃用,同时未记录的别名 crypto.prng()crypto.rng() 也不推荐使用,建议使用 crypto.randomBytes(),并且在将来的版本中可能会被移除。

🌐 In recent versions of Node.js, there is no difference between crypto.randomBytes() and crypto.pseudoRandomBytes(). The latter is deprecated along with the undocumented aliases crypto.prng() and crypto.rng() in favor of crypto.randomBytes() and might be removed in a future release.

DEP0116:旧版 URL API#>

🌐 DEP0116: Legacy URL API

类型:弃用已撤销

🌐 Type: Deprecation revoked

旧版 URL API 已被弃用。这包括 url.format()url.parse()url.resolve()遗留 urlObject。请改用 WHATWG URL API

🌐 The Legacy URL API is deprecated. This includes url.format(), url.parse(), url.resolve(), and the legacy urlObject. Please use the WHATWG URL API instead.

DEP0117:本地加密处理器#>

🌐 DEP0117: Native crypto handles

类型:寿命终止

🌐 Type: End-of-Life

Node.js 的早期版本通过 CipherDecipherDiffieHellmanDiffieHellmanGroupECDHHashHmacSignVerify 类的 _handle 属性暴露了内部原生对象的句柄。由于不当使用原生对象可能导致应用崩溃,因此已移除了 _handle 属性。

🌐 Previous versions of Node.js exposed handles to internal native objects through the _handle property of the Cipher, Decipher, DiffieHellman, DiffieHellmanGroup, ECDH, Hash, Hmac, Sign, and Verify classes. The _handle property has been removed because improper use of the native object can lead to crashing the application.

DEP0118:dns.lookup() 对假值主机名的支持#>

🌐 DEP0118: dns.lookup() support for a falsy host name

类型:运行时

🌐 Type: Runtime

Node.js 的早期版本由于向后兼容性,支持使用假值主机名调用 dns.lookup(),例如 dns.lookup(false)。 这种行为没有文档说明,并且在实际应用中据认为几乎没有使用。 在未来的 Node.js 版本中,这将成为一个错误。

🌐 Previous versions of Node.js supported dns.lookup() with a falsy host name like dns.lookup(false) due to backward compatibility. This behavior is undocumented and is thought to be unused in real world apps. It will become an error in future versions of Node.js.

DEP0119:process.binding('uv').errname() 私有 API#>

🌐 DEP0119: process.binding('uv').errname() private API

类型:仅文档(支持 --pending-deprecation

🌐 Type: Documentation-only (supports --pending-deprecation)

process.binding('uv').errname() 已被弃用。请改用 util.getSystemErrorName()

DEP0120:Windows 性能计数器支持#>

🌐 DEP0120: Windows Performance Counter support

类型:寿命终止

🌐 Type: End-of-Life

Windows 性能计数器支持已从 Node.js 中移除。未记录的 COUNTER_NET_SERVER_CONNECTION()COUNTER_NET_SERVER_CONNECTION_CLOSE()COUNTER_HTTP_SERVER_REQUEST()COUNTER_HTTP_SERVER_RESPONSE()COUNTER_HTTP_CLIENT_REQUEST()COUNTER_HTTP_CLIENT_RESPONSE() 函数已被弃用。

🌐 Windows Performance Counter support has been removed from Node.js. The undocumented COUNTER_NET_SERVER_CONNECTION(), COUNTER_NET_SERVER_CONNECTION_CLOSE(), COUNTER_HTTP_SERVER_REQUEST(), COUNTER_HTTP_SERVER_RESPONSE(), COUNTER_HTTP_CLIENT_REQUEST(), and COUNTER_HTTP_CLIENT_RESPONSE() functions have been deprecated.

DEP0121:net._setSimultaneousAccepts()#>

🌐 DEP0121: net._setSimultaneousAccepts()

类型:运行时

🌐 Type: Runtime

未记录的 net._setSimultaneousAccepts() 函数最初是用于在 Windows 上使用 node:child_processnode:cluster 模块时进行调试和性能调优。该函数通常没有实际用途,现已被移除。讨论请见此处: https://github.com/nodejs/node/issues/18391

DEP0122: tls Server.prototype.setOptions()#>

类型:运行时

🌐 Type: Runtime

请改用 Server.prototype.setSecureContext()

🌐 Please use Server.prototype.setSecureContext() instead.

DEP0123:将 TLS ServerName 设置为 IP 地址#>

🌐 DEP0123: setting the TLS ServerName to an IP address

类型:运行时

🌐 Type: Runtime

将 TLS ServerName 设置为 IP 地址是不被 RFC 6066 允许的。在未来的版本中,这将被忽略。

🌐 Setting the TLS ServerName to an IP address is not permitted by RFC 6066. This will be ignored in a future version.

DEP0124:使用 REPLServer.rli#>

🌐 DEP0124: using REPLServer.rli

类型:寿命终止

🌐 Type: End-of-Life

此属性是对实例本身的引用。

🌐 This property is a reference to the instance itself.

DEP0125: require('node:_stream_wrap')#>

类型:运行时

🌐 Type: Runtime

node:_stream_wrap 模块已被弃用。

🌐 The node:_stream_wrap module is deprecated.

DEP0126: timers.active()#>

类型:运行时

🌐 Type: Runtime

以前未记录的 timers.active() 已被弃用。请改用公开文档中的 timeout.refresh()。如果需要重新引用超时,可以使用 timeout.ref(),自 Node.js 10 起不会影响性能。

🌐 The previously undocumented timers.active() is deprecated. Please use the publicly documented timeout.refresh() instead. If re-referencing the timeout is necessary, timeout.ref() can be used with no performance impact since Node.js 10.

DEP0127:timers._unrefActive()#>

🌐 DEP0127: timers._unrefActive()

类型:运行时

🌐 Type: Runtime

先前未记录且“私有”的 timers._unrefActive() 已被弃用。请改用公开记录的 timeout.refresh()。如果需要取消引用超时,可以使用 timeout.unref(),自 Node.js 10 起不会影响性能。

🌐 The previously undocumented and "private" timers._unrefActive() is deprecated. Please use the publicly documented timeout.refresh() instead. If unreferencing the timeout is necessary, timeout.unref() can be used with no performance impact since Node.js 10.

DEP0128:具有无效 main 条目且包含 index.js 文件的模块#>

🌐 DEP0128: modules with an invalid main entry and an index.js file

类型:运行时

🌐 Type: Runtime

具有无效 main 条目(例如 ./does-not-exist.js)并且在顶层目录中还有 index.js 文件的模块,将会解析 index.js 文件。这种做法已被弃用,并将在未来的 Node.js 版本中抛出错误。

🌐 Modules that have an invalid main entry (e.g., ./does-not-exist.js) and also have an index.js file in the top level directory will resolve the index.js file. That is deprecated and is going to throw an error in future Node.js versions.

DEP0129: ChildProcess._channel#>

类型:运行时

🌐 Type: Runtime

spawn() 和类似函数返回的子进程对象的 _channel 属性不适合公开使用。请改用 ChildProcess.channel

🌐 The _channel property of child process objects returned by spawn() and similar functions is not intended for public use. Use ChildProcess.channel instead.

DEP0130: Module.createRequireFromPath()#>

类型:寿命终止

🌐 Type: End-of-Life

改用module.createRequire()

🌐 Use module.createRequire() instead.

DEP0131:旧版 HTTP 解析器#>

🌐 DEP0131: Legacy HTTP parser

类型:寿命终止

🌐 Type: End-of-Life

在 Node.js 12.0.0 之前的版本中默认使用的传统 HTTP 解析器已被弃用,并在 v13.0.0 中移除。在 v13.0.0 之前,可以使用 --http-parser=legacy 命令行标志回退到使用传统解析器。

🌐 The legacy HTTP parser, used by default in versions of Node.js prior to 12.0.0, is deprecated and has been removed in v13.0.0. Prior to v13.0.0, the --http-parser=legacy command-line flag could be used to revert to using the legacy parser.

DEP0132:带回调的 worker.terminate()#>

🌐 DEP0132: worker.terminate() with callback

类型:运行时

🌐 Type: Runtime

worker.terminate() 传递回调已被弃用。请改用返回的 Promise,或使用 worker 的 'exit' 事件监听器。

🌐 Passing a callback to worker.terminate() is deprecated. Use the returned Promise instead, or a listener to the worker's 'exit' event.

DEP0133:http connection#>

🌐 DEP0133: http connection

类型:仅文档

🌐 Type: Documentation-only

偏好 response.socket 而不是 response.connection,以及偏好 request.socket 而不是 request.connection

🌐 Prefer response.socket over response.connection and request.socket over request.connection.

DEP0134: process._tickCallback#>

类型:仅文档(支持 --pending-deprecation

🌐 Type: Documentation-only (supports --pending-deprecation)

process._tickCallback 属性从未被记录为官方支持的 API。

🌐 The process._tickCallback property was never documented as an officially supported API.

DEP0135:WriteStream.open()ReadStream.open() 是内部的#>

🌐 DEP0135: WriteStream.open() and ReadStream.open() are internal

类型:运行时

🌐 Type: Runtime

WriteStream.open()ReadStream.open() 是未记录的内部 API,在用户空间中使用没有意义。文件流应始终通过其对应的工厂方法 fs.createWriteStream()fs.createReadStream() 打开,或者在选项中传入文件描述符。

DEP0136:http finished#>

🌐 DEP0136: http finished

类型:仅文档

🌐 Type: Documentation-only

response.finished 表示 response.end() 是否已被调用,而不是表示 'finish' 是否已被触发以及底层数据是否已刷新。

相应地使用 response.writableFinishedresponse.writableEnded,以避免产生歧义。

🌐 Use response.writableFinished or response.writableEnded accordingly instead to avoid the ambiguity.

为了保持现有行为,应将 response.finished 替换为 response.writableEnded

🌐 To maintain existing behavior response.finished should be replaced with response.writableEnded.

DEP0137:在垃圾回收时关闭 fs.FileHandle#>

🌐 DEP0137: Closing fs.FileHandle on garbage collection

类型:运行时

🌐 Type: Runtime

允许在垃圾回收时关闭 fs.FileHandle 对象已被弃用。将来,这样做可能会导致抛出错误并终止进程。

🌐 Allowing a fs.FileHandle object to be closed on garbage collection is deprecated. In the future, doing so might result in a thrown error that will terminate the process.

请确保在不再需要 fs.FileHandle 时,使用 FileHandle.prototype.close() 显式关闭所有 fs.FileHandle 对象:

🌐 Please ensure that all fs.FileHandle objects are explicitly closed using FileHandle.prototype.close() when the fs.FileHandle is no longer needed:

const fsPromises = require('node:fs').promises;
async function openAndClose() {
  let filehandle;
  try {
    filehandle = await fsPromises.open('thefile.txt', 'r');
  } finally {
    if (filehandle !== undefined)
      await filehandle.close();
  }
} 

DEP0138: process.mainModule#>

类型:仅文档

🌐 Type: Documentation-only

process.mainModule 是仅限 CommonJS 的功能,而 process 全局对象可以在非 CommonJS 环境中共享。在 ECMAScript 模块中使用它是不支持的。

它已被弃用,建议使用 require.main,因为它具有相同的功能,并且仅在 CommonJS 环境中可用。

🌐 It is deprecated in favor of require.main, because it serves the same purpose and is only available on CommonJS environment.

DEP0139:process.umask() 没有参数#>

🌐 DEP0139: process.umask() with no arguments

类型:仅文档

🌐 Type: Documentation-only

调用不带参数的 process.umask() 会导致全局 umask 被写入两次。这会在线程之间引入竞争条件,并且可能成为安全漏洞。没有安全的跨平台替代 API。

🌐 Calling process.umask() with no argument causes the process-wide umask to be written twice. This introduces a race condition between threads, and is a potential security vulnerability. There is no safe, cross-platform alternative API.

DEP0140:使用 request.destroy() 替代 request.abort()#>

🌐 DEP0140: Use request.destroy() instead of request.abort()

类型:仅文档

🌐 Type: Documentation-only

使用 request.destroy() 替代 request.abort()

🌐 Use request.destroy() instead of request.abort().

DEP0141:repl.inputStreamrepl.outputStream#>

🌐 DEP0141: repl.inputStream and repl.outputStream

类型:仅文档(支持 --pending-deprecation

🌐 Type: Documentation-only (supports --pending-deprecation)

node:repl 模块导出了两次输入和输出流。请使用 .input 替代 .inputStream,使用 .output 替代 .outputStream

🌐 The node:repl module exported the input and output stream twice. Use .input instead of .inputStream and .output instead of .outputStream.

DEP0142:repl._builtinLibs#>

🌐 DEP0142: repl._builtinLibs

类型:仅文档

🌐 Type: Documentation-only

node:repl 模块导出了一个 _builtinLibs 属性,其中包含一个内置模块的数组。到目前为止它还不完整,因此更好的是依赖 require('node:module').builtinModules

🌐 The node:repl module exports a _builtinLibs property that contains an array of built-in modules. It was incomplete so far and instead it's better to rely upon require('node:module').builtinModules.

DEP0143: Transform._transformState#>

类型:运行时 Transform._transformState将在将来的版本中被移除,因为随着实现的简化,它将不再需要。

🌐 Type: Runtime Transform._transformState will be removed in future versions where it is no longer required due to simplification of the implementation.

DEP0144: module.parent#>

类型:仅文档(支持 --pending-deprecation

🌐 Type: Documentation-only (supports --pending-deprecation)

CommonJS 模块可以通过 module.parent 访问第一个导入它的模块。由于在存在 ECMAScript 模块时此功能无法一致工作,并且它会对 CommonJS 模块图提供不准确的表示,因此该功能已被弃用。

🌐 A CommonJS module can access the first module that required it using module.parent. This feature is deprecated because it does not work consistently in the presence of ECMAScript modules and because it gives an inaccurate representation of the CommonJS module graph.

一些模块使用它来检查它们是否是当前进程的入口点。相反,建议比较 require.mainmodule

🌐 Some modules use it to check if they are the entry point of the current process. Instead, it is recommended to compare require.main and module:

if (require.main === module) {
  // Code section that will run only if current file is the entry point.
} 

在查找已经引用当前模块的 CommonJS 模块时,可以使用 require.cachemodule.children

🌐 When looking for the CommonJS modules that have required the current one, require.cache and module.children can be used:

const moduleParents = Object.values(require.cache)
  .filter((m) => m.children.includes(module)); 

DEP0145: socket.bufferSize#>

类型:仅文档

🌐 Type: Documentation-only

socket.bufferSize只是writable.writableLength的别名。

DEP0146: new crypto.Certificate()#>

类型:仅文档

🌐 Type: Documentation-only

crypto.Certificate() 构造函数 已不推荐使用。请改用 crypto.Certificate() 的静态方法

🌐 The crypto.Certificate() constructor is deprecated. Use static methods of crypto.Certificate() instead.

DEP0147: fs.rmdir(path, { recursive: true })#>

类型:运行时

🌐 Type: Runtime

在未来版本的 Node.js 中,fs.rmdirfs.rmdirSyncfs.promises.rmdirrecursive 选项将被忽略。

🌐 In future versions of Node.js, recursive option will be ignored for fs.rmdir, fs.rmdirSync, and fs.promises.rmdir.

请使用 fs.rm(path, { recursive: true, force: true })fs.rmSync(path, { recursive: true, force: true })fs.promises.rm(path, { recursive: true, force: true })

🌐 Use fs.rm(path, { recursive: true, force: true }), fs.rmSync(path, { recursive: true, force: true }) or fs.promises.rm(path, { recursive: true, force: true }) instead.

DEP0148:'“exports”中的文件夹映射(后尾是“/”')#>

🌐 DEP0148: Folder mappings in "exports" (trailing "/")

类型:运行时

🌐 Type: Runtime

子路径导出子路径导入 字段中使用尾随的 / 来定义 子路径文件夹映射 已被弃用。请改用 子路径模式

🌐 Using a trailing "/" to define subpath folder mappings in the subpath exports or subpath imports fields is deprecated. Use subpath patterns instead.

DEP0149:http.IncomingMessage#connection#>

🌐 DEP0149: http.IncomingMessage#connection

类型:仅文档。

🌐 Type: Documentation-only.

更喜欢 message.socket 而不是 message.connection

🌐 Prefer message.socket over message.connection.

DEP0150:更改 process.config 的值#>

🌐 DEP0150: Changing the value of process.config

类型:运行时

🌐 Type: Runtime

process.config 属性提供对 Node.js 编译时设置的访问。然而,该属性是可变的,因此可能被篡改。将来版本的 Node.js 中将移除修改其值的能力。

🌐 The process.config property provides access to Node.js compile-time settings. However, the property is mutable and therefore subject to tampering. The ability to change the value will be removed in a future version of Node.js.

DEP0151:主索引查找和扩展搜索#>

🌐 DEP0151: Main index lookup and extension searching

类型:运行时

🌐 Type: Runtime

以前,index.js 和扩展名搜索查找会应用于 import 'pkg' 的主入口点解析,即使是在解析 ES 模块时也是如此。

🌐 Previously, index.js and extension searching lookups would apply to import 'pkg' main entry point resolution, even when resolving ES modules.

随着此弃用,所有 ES 模块主入口点解析都需要使用带有确切文件扩展名的显式 "exports""main" 入口

🌐 With this deprecation, all ES module main entry point resolutions require an explicit "exports" or "main" entry with the exact file extension.

DEP0152:扩展 PerformanceEntry 属性#>

🌐 DEP0152: Extension PerformanceEntry properties

类型:运行时

🌐 Type: Runtime

'gc'、'http2' 和 'http' <PerformanceEntry> 对象类型被分配了额外的属性,这些属性提供了额外的信息。这些属性现在可以通过 PerformanceEntry 对象的标准 detail 属性获取。现有的访问器已被弃用,不应再使用。

🌐 The 'gc', 'http2', and 'http' <PerformanceEntry> object types have additional properties assigned to them that provide additional information. These properties are now available within the standard detail property of the PerformanceEntry object. The existing accessors have been deprecated and should no longer be used.

DEP0153:dns.lookupdnsPromises.lookup 选项类型强制转换#>

🌐 DEP0153: dns.lookup and dnsPromises.lookup options type coercion

类型:仅文档

🌐 Type: Documentation-only

dns.lookup()dnsPromises.lookup() 中,为 family 选项使用非 nullish 的非整数值,为 hints 选项使用非 nullish 的非数字值,为 all 选项使用非 nullish 的非布尔值,或为 verbatim 选项使用非 nullish 的非布尔值的做法已被弃用。

🌐 Using a non-nullish non-integer value for family option, a non-nullish non-number value for hints option, a non-nullish non-boolean value for all option, or a non-nullish non-boolean value for verbatim option in dns.lookup() and dnsPromises.lookup() is deprecated.

DEP0154:RSA-PSS 生成密钥对选项#>

🌐 DEP0154: RSA-PSS generate key pair options

类型:仅文档(支持 --pending-deprecation

🌐 Type: Documentation-only (supports --pending-deprecation)

'hash''mgf1Hash' 选项已被 'hashAlgorithm''mgf1HashAlgorithm' 取代。

🌐 The 'hash' and 'mgf1Hash' options are replaced with 'hashAlgorithm' and 'mgf1HashAlgorithm'.

DEP0155:模式说明符解析中的尾随斜杠#>

🌐 DEP0155: Trailing slashes in pattern specifier resolutions

类型:仅文档(支持 --pending-deprecation

🌐 Type: Documentation-only (supports --pending-deprecation)

像“import 'pkg/x/''”这类以“/”结尾的指定词重新映射被淘汰了 用于包的“导出”和“导入”模式分辨率。

🌐 The remapping of specifiers ending in "/" like import 'pkg/x/' is deprecated for package "exports" and "imports" pattern resolutions.

DEP0156:http 中的 .aborted 属性以及 'abort''aborted' 事件#>

🌐 DEP0156: .aborted property and 'abort', 'aborted' event in http

类型:仅文档

🌐 Type: Documentation-only

改为使用 <Stream> API,因为 http.ClientRequesthttp.ServerResponsehttp.IncomingMessage 都是基于流的。请检查 stream.destroyed 而不是 .aborted 属性,并监听 'close' 事件,而不是 'abort''aborted' 事件。

🌐 Move to <Stream> API instead, as the http.ClientRequest, http.ServerResponse, and http.IncomingMessage are all stream-based. Check stream.destroyed instead of the .aborted property, and listen for 'close' instead of 'abort', 'aborted' event.

.aborted 属性和 'abort' 事件仅用于检测 .abort() 调用。要提前关闭请求,请使用 Stream 的 .destroy([error]),然后检查 .destroyed 属性,'close' 事件应该会有相同的效果。接收端还应检查 http.IncomingMessage 上的 readable.readableEnded 值,以确定是被中止还是正常销毁。

🌐 The .aborted property and 'abort' event are only useful for detecting .abort() calls. For closing a request early, use the Stream .destroy([error]) then check the .destroyed property and 'close' event should have the same effect. The receiving end should also check the readable.readableEnded value on http.IncomingMessage to get whether it was an aborted or graceful destroy.

DEP0157:流中的可 then 对象支持#>

🌐 DEP0157: Thenable support in streams

类型:仅文档

🌐 Type: Documentation-only

Node.js 流的一个未记录功能是支持在实现方法中使用 thenable。这现已被弃用,请改用回调,并避免在流的实现方法中使用异步函数。

🌐 An undocumented feature of Node.js streams was to support thenables in implementation methods. This is now deprecated, use callbacks instead and avoid use of async function for streams implementation methods.

此功能导致用户遇到意外问题,例如用户以回调方式实现函数,但使用了异步方法,这会导致错误,因为混合使用 Promise 和回调语义是无效的。

🌐 This feature caused users to encounter unexpected problems where the user implements the function in callback style but uses e.g. an async method which would cause an error since mixing promise and callback semantics is not valid.

const w = new Writable({
  async final(callback) {
    await someOp();
    callback();
  }
}); 

DEP0158: buffer.slice(start, end)#>

类型:仅文档

🌐 Type: Documentation-only

此方法已被弃用,因为它与 Uint8Array.prototype.slice() 不兼容,而 Uint8Array.prototype.slice()Buffer 的超类。

🌐 This method was deprecated because it is not compatible with Uint8Array.prototype.slice(), which is a superclass of Buffer.

改用功能相同的buffer.subarray

🌐 Use buffer.subarray which does the same thing instead.

DEP0160:process.on('multipleResolves', handler)#>

🌐 DEP0160: process.on('multipleResolves', handler)

类型:仅文档

🌐 Type: Documentation-only

这个事件已被弃用,因为它无法与 V8 的 promise 组合器一起使用,导致其实用性降低。

🌐 This event was deprecated because it did not work with V8 promise combinators which diminished its usefulness.

DEP0161:process._getActiveRequests()process._getActiveHandles()#>

🌐 DEP0161: process._getActiveRequests() and process._getActiveHandles()

类型:仅文档

🌐 Type: Documentation-only

process._getActiveHandles()process._getActiveRequests() 函数不适合公开使用,未来版本可能会被移除。

🌐 The process._getActiveHandles() and process._getActiveRequests() functions are not intended for public use and can be removed in future releases.

使用 process.getActiveResourcesInfo() 获取活动资源类型的列表,而不是实际引用。

🌐 Use process.getActiveResourcesInfo() to get a list of types of active resources and not the actual references.

DEP0162:fs.write()fs.writeFileSync() 强制转换为字符串#>

🌐 DEP0162: fs.write(), fs.writeFileSync() coercion to string

类型:仅文档

🌐 Type: Documentation-only

将具有自身 toString 属性的对象作为 fs.write()fs.writeFile()fs.appendFile()fs.writeFileSync()fs.appendFileSync() 的第二个参数隐式强制转换已被弃用。请将它们转换为原始字符串。

🌐 Implicit coercion of objects with own toString property, passed as second parameter in fs.write(), fs.writeFile(), fs.appendFile(), fs.writeFileSync(), and fs.appendFileSync() is deprecated. Convert them to primitive strings.

DEP0163:channel.subscribe(onMessage)channel.unsubscribe(onMessage)#>

🌐 DEP0163: channel.subscribe(onMessage), channel.unsubscribe(onMessage)

类型:仅文档

🌐 Type: Documentation-only

这些方法已被弃用,因为它们可能被用于一种不能保持通道引用足够长时间以接收事件的方式。

🌐 These methods were deprecated because they can be used in a way which does not hold the channel reference alive long enough to receive the events.

改用 diagnostics_channel.subscribe(name, onMessage)diagnostics_channel.unsubscribe(name, onMessage),它们做的事情一样。

🌐 Use diagnostics_channel.subscribe(name, onMessage) or diagnostics_channel.unsubscribe(name, onMessage) which does the same thing instead.

DEP0164:process.exit(code)process.exitCode 强制转换为整数#>

🌐 DEP0164: process.exit(code), process.exitCode coercion to integer

类型:仅文档

🌐 Type: Documentation-only

undefinednull、整数和整数字符串(例如 '1')之外的值,作为 process.exit()code 参数的值以及作为赋值给 process.exitCode 的值,已被弃用。

🌐 Values other than undefined, null, integer numbers, and integer strings (e.g., '1') are deprecated as value for the code parameter in process.exit() and as value to assign to process.exitCode.

DEP0165: --trace-atomics-wait#>

类型:仅文档

🌐 Type: Documentation-only

--trace-atomics-wait 标志已被淘汰。

🌐 The --trace-atomics-wait flag is deprecated.

DEP0167:弱的 DiffieHellmanGroup 实例(modp1modp2modp5#>

🌐 DEP0167: Weak DiffieHellmanGroup instances (modp1, modp2, modp5)

类型:仅文档

🌐 Type: Documentation-only

著名的 MODP 组 modp1modp2modp5 已被弃用,因为它们不能抵御实际攻击。详情见 RFC 8247 第 2.4 节

🌐 The well-known MODP groups modp1, modp2, and modp5 are deprecated because they are not secure against practical attacks. See RFC 8247 Section 2.4 for details.

这些组可能会在未来的 Node.js 版本中被移除。依赖这些组的应用应考虑使用更强的 MODP 组。

🌐 These groups might be removed in future versions of Node.js. Applications that rely on these groups should evaluate using stronger MODP groups instead.

DEP0168:Node-API 回调中的未处理异常#>

🌐 DEP0168: Unhandled exception in Node-API callbacks

类型:运行时。

🌐 Type: Runtime.

现在已不推荐在 Node-API 回调中隐式抑制未捕获的异常。

🌐 The implicit suppression of uncaught exceptions in Node-API callbacks is now deprecated.

设置标志 --force-node-api-uncaught-exceptions-policy,以强制 Node.js 在 Node-API 回调中未处理异常时发出 'uncaughtException' 事件。

🌐 Set the flag --force-node-api-uncaught-exceptions-policy to force Node.js to emit an 'uncaughtException' event if the exception is not handled in Node-API callbacks.

Node.js 中文网 - 粤ICP备13048890号