- assert 断言
- async_hooks 异步钩子
- async_hooks/context 异步上下文
- buffer 缓冲区
- C++插件
- C/C++插件(使用Node-API)
- C++嵌入器
- child_process 子进程
- cluster 集群
- CLI 命令行
- console 控制台
- Corepack 核心包
- crypto 加密
- crypto/webcrypto 网络加密
- debugger 调试器
- deprecation 弃用
- dgram 数据报
- diagnostics_channel 诊断通道
- dns 域名服务器
- domain 域
- Error 错误
- events 事件触发器
- fs 文件系统
- global 全局变量
- http 超文本传输协议
- http2 超文本传输协议2.0
- https 安全超文本传输协议
- inspector 检查器
- Intl 国际化
- module 模块
- module/cjs CommonJS模块
- module/esm ECMAScript模块
- module/package 包模块
- net 网络
- os 操作系统
- path 路径
- perf_hooks 性能钩子
- permission 权限
- process 进程
- punycode 域名代码
- querystring 查询字符串
- readline 逐行读取
- repl 交互式解释器
- report 诊断报告
- sea 单个可执行应用程序
- stream 流
- stream/web 网络流
- string_decoder 字符串解码器
- test 测试
- timers 定时器
- tls 安全传输层
- trace_events 跟踪事件
- tty 终端
- url 网址
- util 实用工具
- v8 引擎
- vm 虚拟机
- wasi 网络汇编系统接口
- worker_threads 工作线程
- zlib 压缩
Node.js v18.16.0 文档
- Node.js v18.16.0
-
►
目录
- 弃用的 API
- 撤销弃用
- 已弃用的 API 列表
- DEP0001:
http.OutgoingMessage.prototype.flush
- DEP0002:
require('_linklist')
- DEP0003:
_writableState.buffer
- DEP0004:
CryptoStream.prototype.readyState
- DEP0005:
Buffer()
构造函数 - DEP0006:
child_process
options.customFds
- DEP0007:用
worker.exitedAfterDisconnect
替换cluster
worker.suicide
- DEP0008:
require('node:constants')
- DEP0009:没有摘要的
crypto.pbkdf2
- DEP0010:
crypto.createCredentials
- DEP0011:
crypto.Credentials
- DEP0012:
Domain.dispose
- DEP0013:没有回调的
fs
异步函数 - DEP0014:
fs.read
旧版字符串接口 - DEP0015:
fs.readSync
旧版字符串接口 - DEP0016:
GLOBAL
/root
- DEP0017:
Intl.v8BreakIterator
- DEP0018:未处理的 promise 拒绝
- DEP0019:
require('.')
在外部目录中解析 - DEP0020:
Server.connections
- DEP0021:
Server.listenFD
- DEP0022:
os.tmpDir()
- DEP0023:
os.getNetworkInterfaces()
- DEP0024:
REPLServer.prototype.convertToContext()
- DEP0025:
require('node:sys')
- DEP0026:
util.print()
- DEP0027:
util.puts()
- DEP0028:
util.debug()
- DEP0029:
util.error()
- DEP0030:
SlowBuffer
- DEP0031:
ecdh.setPublicKey()
- DEP0032:
node:domain
模块 - DEP0033:
EventEmitter.listenerCount()
- DEP0034:
fs.exists(path, callback)
- DEP0035:
fs.lchmod(path, mode, callback)
- DEP0036:
fs.lchmodSync(path, mode)
- DEP0037:
fs.lchown(path, uid, gid, callback)
- DEP0038:
fs.lchownSync(path, uid, gid)
- DEP0039:
require.extensions
- DEP0040:
node:punycode
模块 - DEP0041:
NODE_REPL_HISTORY_FILE
环境变量 - DEP0042:
tls.CryptoStream
- DEP0043:
tls.SecurePair
- DEP0044:
util.isArray()
- DEP0045:
util.isBoolean()
- DEP0046:
util.isBuffer()
- DEP0047:
util.isDate()
- DEP0048:
util.isError()
- DEP0049:
util.isFunction()
- DEP0050:
util.isNull()
- DEP0051:
util.isNullOrUndefined()
- DEP0052:
util.isNumber()
- DEP0053:
util.isObject()
- DEP0054:
util.isPrimitive()
- DEP0055:
util.isRegExp()
- DEP0056:
util.isString()
- DEP0057:
util.isSymbol()
- DEP0058:
util.isUndefined()
- DEP0059:
util.log()
- DEP0060:
util._extend()
- DEP0061:
fs.SyncWriteStream
- DEP0062:
node --debug
- DEP0063:
ServerResponse.prototype.writeHeader()
- DEP0064:
tls.createSecurePair()
- DEP0065:
repl.REPL_MODE_MAGIC
和NODE_REPL_MODE=magic
- DEP0066:
OutgoingMessage.prototype._headers, OutgoingMessage.prototype._headerNames
- DEP0067:
OutgoingMessage.prototype._renderHeaders
- DEP0068:
node debug
- DEP0069:
vm.runInDebugContext(string)
- DEP0070:
async_hooks.currentId()
- DEP0071:
async_hooks.triggerId()
- DEP0072:
async_hooks.AsyncResource.triggerId()
- DEP0073:
net.Server
的几个内部属性 - DEP0074:
REPLServer.bufferedCommand
- DEP0075:
REPLServer.parseREPLKeyword()
- DEP0076:
tls.parseCertString()
- DEP0077:
Module._debug()
- DEP0078:
REPLServer.turnOffEditorMode()
- DEP0079:通过
.inspect()
对对象的自定义检查函数 - DEP0080:
path._makeLong()
- DEP0081:
fs.truncate()
使用文件描述符 - DEP0082:
REPLServer.prototype.memory()
- DEP0083:通过将
ecdhCurve
设置为false
来禁用 ECDH - DEP0084:需要捆绑的内部依赖项
- DEP0085:AsyncHooks 敏感 API
- DEP0086:删除
runInAsyncIdScope
- DEP0089:
require('node:assert')
- DEP0090:无效的 GCM 身份验证标签长度
- DEP0091:
crypto.DEFAULT_ENCODING
- DEP0092:顶层
this
绑定到module.exports
- DEP0093:
crypto.fips
已弃用并被替换 - DEP0094:将
assert.fail()
与多个参数一起使用 - DEP0095:
timers.enroll()
- DEP0096:
timers.unenroll()
- DEP0097:具有
domain
属性的MakeCallback
- DEP0098:AsyncHooks 嵌入器
AsyncResource.emitBefore
和AsyncResource.emitAfter
API - DEP0099:异步上下文不感知的
node::MakeCallback
C++ API - DEP0100:
process.assert()
- DEP0101:
--with-lttng
- DEP0102:在
Buffer#(read|write)
操作中使用noAssert
- DEP0103:
process.binding('util').is[...]
类型检查 - DEP0104:
process.env
字符串强制转换 - DEP0105:
decipher.finaltol
- DEP0106:
crypto.createCipher
和crypto.createDecipher
- DEP0107:
tls.convertNPNProtocols()
- DEP0108:
zlib.bytesRead
- DEP0109:
http
、https
和tls
支持无效 URL - DEP0110:
vm.Script
缓存数据 - DEP0111:
process.binding()
- DEP0112:
dgram
私有 API - DEP0113:
Cipher.setAuthTag()
,Decipher.getAuthTag()
- DEP0114:
crypto._toBuf()
- DEP0115:
crypto.prng()
、crypto.pseudoRandomBytes()
、crypto.rng()
- DEP0116:旧版 URL API
- DEP0117:原生加密句柄
- DEP0118:
dns.lookup()
支持虚假主机名 - DEP0119:
process.binding('uv').errname()
私有 API - DEP0120:Windows 性能计数器支持
- DEP0121:
net._setSimultaneousAccepts()
- DEP0122:
tls
Server.prototype.setOptions()
- DEP0123:将 TLS ServerName 设置为 IP 地址
- DEP0124:使用
REPLServer.rli
- DEP0125:
require('node:_stream_wrap')
- DEP0126:
timers.active()
- DEP0127:
timers._unrefActive()
- DEP0128:具有无效
main
条目和index.js
文件的模块 - DEP0129:
ChildProcess._channel
- DEP0130:
Module.createRequireFromPath()
- DEP0131:旧版 HTTP 解析器
- DEP0132:带有回调的
worker.terminate()
- DEP0133:
http
connection
- DEP0134:
process._tickCallback
- DEP0135:
WriteStream.open()
和ReadStream.open()
是内部的 - DEP0136:
http
finished
- DEP0137:在垃圾回收时关闭 fs.FileHandle
- DEP0138:
process.mainModule
- DEP0139:没有参数的
process.umask()
- DEP0140:使用
request.destroy()
而不是request.abort()
- DEP0141:
repl.inputStream
和repl.outputStream
- DEP0142:
repl._builtinLibs
- DEP0143:
Transform._transformState
- DEP0144:
module.parent
- DEP0145:
socket.bufferSize
- DEP0146:
new crypto.Certificate()
- DEP0147:
fs.rmdir(path, { recursive: true })
- DEP0148:
"exports"
中的文件夹映射(尾随"/"
) - DEP0149:
http.IncomingMessage#connection
- DEP0150:更改
process.config
的值 - DEP0151:主索引查找和扩展搜索
- DEP0152:扩展 PerformanceEntry 属性
- DEP0153:
dns.lookup
和dnsPromises.lookup
选项类型强制转换 - DEP0154:RSA-PSS 生成密钥对选项
- DEP0155:模式说明符解析中的尾部斜线
- DEP0156:
http
中的.aborted
属性和'abort'
、'aborted'
事件 - DEP0157:流中的 Thenable 支持
- DEP0158:
buffer.slice(start, end)
- DEP0159:
ERR_INVALID_CALLBACK
- DEP0160:
process.on('multipleResolves', handler)
- DEP0161:
process._getActiveRequests()
和process._getActiveHandles()
- DEP0162:
fs.write()
、fs.writeFileSync()
强制转换为字符串 - DEP0163:
channel.subscribe(onMessage)
,channel.unsubscribe(onMessage)
- DEP0164:
process.exit(code)
、process.exitCode
强制转换为整数 - DEP0165:
--trace-atomics-wait
- DEP0166:导入导出目标中的双斜线
- DEP0167:弱
DiffieHellmanGroup
实例(modp1
、modp2
、modp5
) - DEP0168:Node-API 回调中未处理的异常
- DEP0169:不安全的 url.parse()
- DEP0170:使用
url.parse()
时端口无效 - DEP0171:
http.IncomingMessage
标头和尾部的设置器
- DEP0001:
- 弃用的 API
-
►
导航
- assert 断言
- async_hooks 异步钩子
- async_hooks/context 异步上下文
- buffer 缓冲区
- C++插件
- C/C++插件(使用Node-API)
- C++嵌入器
- child_process 子进程
- cluster 集群
- CLI 命令行
- console 控制台
- Corepack 核心包
- crypto 加密
- crypto/webcrypto 网络加密
- debugger 调试器
- deprecation 弃用
- dgram 数据报
- diagnostics_channel 诊断通道
- dns 域名服务器
- domain 域
- Error 错误
- events 事件触发器
- fs 文件系统
- global 全局变量
- http 超文本传输协议
- http2 超文本传输协议2.0
- https 安全超文本传输协议
- inspector 检查器
- Intl 国际化
- module 模块
- module/cjs CommonJS模块
- module/esm ECMAScript模块
- module/package 包模块
- net 网络
- os 操作系统
- path 路径
- perf_hooks 性能钩子
- permission 权限
- process 进程
- punycode 域名代码
- querystring 查询字符串
- readline 逐行读取
- repl 交互式解释器
- report 诊断报告
- sea 单个可执行应用程序
- stream 流
- stream/web 网络流
- string_decoder 字符串解码器
- test 测试
- timers 定时器
- tls 安全传输层
- trace_events 跟踪事件
- tty 终端
- url 网址
- util 实用工具
- v8 引擎
- vm 虚拟机
- wasi 网络汇编系统接口
- worker_threads 工作线程
- zlib 压缩
- ► 其他版本
- 云服务器
目录
- 弃用的 API
- 撤销弃用
- 已弃用的 API 列表
- DEP0001:
http.OutgoingMessage.prototype.flush
- DEP0002:
require('_linklist')
- DEP0003:
_writableState.buffer
- DEP0004:
CryptoStream.prototype.readyState
- DEP0005:
Buffer()
构造函数 - DEP0006:
child_process
options.customFds
- DEP0007:用
worker.exitedAfterDisconnect
替换cluster
worker.suicide
- DEP0008:
require('node:constants')
- DEP0009:没有摘要的
crypto.pbkdf2
- DEP0010:
crypto.createCredentials
- DEP0011:
crypto.Credentials
- DEP0012:
Domain.dispose
- DEP0013:没有回调的
fs
异步函数 - DEP0014:
fs.read
旧版字符串接口 - DEP0015:
fs.readSync
旧版字符串接口 - DEP0016:
GLOBAL
/root
- DEP0017:
Intl.v8BreakIterator
- DEP0018:未处理的 promise 拒绝
- DEP0019:
require('.')
在外部目录中解析 - DEP0020:
Server.connections
- DEP0021:
Server.listenFD
- DEP0022:
os.tmpDir()
- DEP0023:
os.getNetworkInterfaces()
- DEP0024:
REPLServer.prototype.convertToContext()
- DEP0025:
require('node:sys')
- DEP0026:
util.print()
- DEP0027:
util.puts()
- DEP0028:
util.debug()
- DEP0029:
util.error()
- DEP0030:
SlowBuffer
- DEP0031:
ecdh.setPublicKey()
- DEP0032:
node:domain
模块 - DEP0033:
EventEmitter.listenerCount()
- DEP0034:
fs.exists(path, callback)
- DEP0035:
fs.lchmod(path, mode, callback)
- DEP0036:
fs.lchmodSync(path, mode)
- DEP0037:
fs.lchown(path, uid, gid, callback)
- DEP0038:
fs.lchownSync(path, uid, gid)
- DEP0039:
require.extensions
- DEP0040:
node:punycode
模块 - DEP0041:
NODE_REPL_HISTORY_FILE
环境变量 - DEP0042:
tls.CryptoStream
- DEP0043:
tls.SecurePair
- DEP0044:
util.isArray()
- DEP0045:
util.isBoolean()
- DEP0046:
util.isBuffer()
- DEP0047:
util.isDate()
- DEP0048:
util.isError()
- DEP0049:
util.isFunction()
- DEP0050:
util.isNull()
- DEP0051:
util.isNullOrUndefined()
- DEP0052:
util.isNumber()
- DEP0053:
util.isObject()
- DEP0054:
util.isPrimitive()
- DEP0055:
util.isRegExp()
- DEP0056:
util.isString()
- DEP0057:
util.isSymbol()
- DEP0058:
util.isUndefined()
- DEP0059:
util.log()
- DEP0060:
util._extend()
- DEP0061:
fs.SyncWriteStream
- DEP0062:
node --debug
- DEP0063:
ServerResponse.prototype.writeHeader()
- DEP0064:
tls.createSecurePair()
- DEP0065:
repl.REPL_MODE_MAGIC
和NODE_REPL_MODE=magic
- DEP0066:
OutgoingMessage.prototype._headers, OutgoingMessage.prototype._headerNames
- DEP0067:
OutgoingMessage.prototype._renderHeaders
- DEP0068:
node debug
- DEP0069:
vm.runInDebugContext(string)
- DEP0070:
async_hooks.currentId()
- DEP0071:
async_hooks.triggerId()
- DEP0072:
async_hooks.AsyncResource.triggerId()
- DEP0073:
net.Server
的几个内部属性 - DEP0074:
REPLServer.bufferedCommand
- DEP0075:
REPLServer.parseREPLKeyword()
- DEP0076:
tls.parseCertString()
- DEP0077:
Module._debug()
- DEP0078:
REPLServer.turnOffEditorMode()
- DEP0079:通过
.inspect()
对对象的自定义检查函数 - DEP0080:
path._makeLong()
- DEP0081:
fs.truncate()
使用文件描述符 - DEP0082:
REPLServer.prototype.memory()
- DEP0083:通过将
ecdhCurve
设置为false
来禁用 ECDH - DEP0084:需要捆绑的内部依赖项
- DEP0085:AsyncHooks 敏感 API
- DEP0086:删除
runInAsyncIdScope
- DEP0089:
require('node:assert')
- DEP0090:无效的 GCM 身份验证标签长度
- DEP0091:
crypto.DEFAULT_ENCODING
- DEP0092:顶层
this
绑定到module.exports
- DEP0093:
crypto.fips
已弃用并被替换 - DEP0094:将
assert.fail()
与多个参数一起使用 - DEP0095:
timers.enroll()
- DEP0096:
timers.unenroll()
- DEP0097:具有
domain
属性的MakeCallback
- DEP0098:AsyncHooks 嵌入器
AsyncResource.emitBefore
和AsyncResource.emitAfter
API - DEP0099:异步上下文不感知的
node::MakeCallback
C++ API - DEP0100:
process.assert()
- DEP0101:
--with-lttng
- DEP0102:在
Buffer#(read|write)
操作中使用noAssert
- DEP0103:
process.binding('util').is[...]
类型检查 - DEP0104:
process.env
字符串强制转换 - DEP0105:
decipher.finaltol
- DEP0106:
crypto.createCipher
和crypto.createDecipher
- DEP0107:
tls.convertNPNProtocols()
- DEP0108:
zlib.bytesRead
- DEP0109:
http
、https
和tls
支持无效 URL - DEP0110:
vm.Script
缓存数据 - DEP0111:
process.binding()
- DEP0112:
dgram
私有 API - DEP0113:
Cipher.setAuthTag()
,Decipher.getAuthTag()
- DEP0114:
crypto._toBuf()
- DEP0115:
crypto.prng()
、crypto.pseudoRandomBytes()
、crypto.rng()
- DEP0116:旧版 URL API
- DEP0117:原生加密句柄
- DEP0118:
dns.lookup()
支持虚假主机名 - DEP0119:
process.binding('uv').errname()
私有 API - DEP0120:Windows 性能计数器支持
- DEP0121:
net._setSimultaneousAccepts()
- DEP0122:
tls
Server.prototype.setOptions()
- DEP0123:将 TLS ServerName 设置为 IP 地址
- DEP0124:使用
REPLServer.rli
- DEP0125:
require('node:_stream_wrap')
- DEP0126:
timers.active()
- DEP0127:
timers._unrefActive()
- DEP0128:具有无效
main
条目和index.js
文件的模块 - DEP0129:
ChildProcess._channel
- DEP0130:
Module.createRequireFromPath()
- DEP0131:旧版 HTTP 解析器
- DEP0132:带有回调的
worker.terminate()
- DEP0133:
http
connection
- DEP0134:
process._tickCallback
- DEP0135:
WriteStream.open()
和ReadStream.open()
是内部的 - DEP0136:
http
finished
- DEP0137:在垃圾回收时关闭 fs.FileHandle
- DEP0138:
process.mainModule
- DEP0139:没有参数的
process.umask()
- DEP0140:使用
request.destroy()
而不是request.abort()
- DEP0141:
repl.inputStream
和repl.outputStream
- DEP0142:
repl._builtinLibs
- DEP0143:
Transform._transformState
- DEP0144:
module.parent
- DEP0145:
socket.bufferSize
- DEP0146:
new crypto.Certificate()
- DEP0147:
fs.rmdir(path, { recursive: true })
- DEP0148:
"exports"
中的文件夹映射(尾随"/"
) - DEP0149:
http.IncomingMessage#connection
- DEP0150:更改
process.config
的值 - DEP0151:主索引查找和扩展搜索
- DEP0152:扩展 PerformanceEntry 属性
- DEP0153:
dns.lookup
和dnsPromises.lookup
选项类型强制转换 - DEP0154:RSA-PSS 生成密钥对选项
- DEP0155:模式说明符解析中的尾部斜线
- DEP0156:
http
中的.aborted
属性和'abort'
、'aborted'
事件 - DEP0157:流中的 Thenable 支持
- DEP0158:
buffer.slice(start, end)
- DEP0159:
ERR_INVALID_CALLBACK
- DEP0160:
process.on('multipleResolves', handler)
- DEP0161:
process._getActiveRequests()
和process._getActiveHandles()
- DEP0162:
fs.write()
、fs.writeFileSync()
强制转换为字符串 - DEP0163:
channel.subscribe(onMessage)
,channel.unsubscribe(onMessage)
- DEP0164:
process.exit(code)
、process.exitCode
强制转换为整数 - DEP0165:
--trace-atomics-wait
- DEP0166:导入导出目标中的双斜线
- DEP0167:弱
DiffieHellmanGroup
实例(modp1
、modp2
、modp5
) - DEP0168:Node-API 回调中未处理的异常
- DEP0169:不安全的 url.parse()
- DEP0170:使用
url.parse()
时端口无效 - DEP0171:
http.IncomingMessage
标头和尾部的设置器
- DEP0001:
弃用的 API#
Node.js API 可能由于以下任何原因而被弃用:
- 该 API 的使用是不安全的。
- 改进的替代 API 可用。
- 预计在未来的主要版本中会对 API 进行重大更改。
Node.js 使用了三种弃用:
- 仅文档
- 运行时
- 生命结束
仅文档弃用是仅在 Node.js API 文档中表达的弃用。 这些在运行 Node.js 时不会产生副作用。
某些仅文档的弃用在使用 --pending-deprecation
标志(或其替代的 NODE_PENDING_DEPRECATION=1
环境变量)启动时会触发运行时警告,类似于下面的运行时弃用。 支持该标志的仅文档弃用在 弃用的 API 列表 中明确标记为此类。
默认情况下,运行时弃用将生成进程警告,该警告将在第一次使用弃用的 API 时打印到 stderr
。 当使用 --throw-deprecation
命令行标志时,运行时弃用将导致抛出错误。
当特性已经或即将从 Node.js 中删除时,使用生命结束的弃用。
撤销弃用#
有时,API 的弃用可能会被逆转。 在这种情况下,本文件将更新与决定相关的信息。 但是,弃用标识符不会被修改。
已弃用的 API 列表#
DEP0001:http.OutgoingMessage.prototype.flush
#
类型: 生命结束
OutgoingMessage.prototype.flush()
已被删除。 改用 OutgoingMessage.prototype.flushHeaders()
。
DEP0002:require('_linklist')
#
类型: 生命结束
_linklist
模块已弃用。 请使用用户空间替代方案。
DEP0003:_writableState.buffer
#
类型: 生命结束
_writableState.buffer
已被移除。 改用 _writableState.getBuffer()
。
DEP0004:CryptoStream.prototype.readyState
#
类型: 生命结束
CryptoStream.prototype.readyState
属性已被删除。
DEP0005:Buffer()
构造函数#
类型: 运行时(支持 --pending-deprecation
)
由于可能导致意外安全问题的 API 可用性问题,Buffer()
函数和 new Buffer()
构造函数已弃用。
作为替代方案,使用以下方法之一构造 Buffer
对象:
Buffer.alloc(size[, fill[, encoding]])
: 创建一个带有初始化内存的Buffer
。Buffer.allocUnsafe(size)
: 使用未初始化的内存创建Buffer
。Buffer.allocUnsafeSlow(size)
: 使用未初始化的内存创建Buffer
。Buffer.from(array)
: 使用array
的副本创建Buffer
Buffer.from(arrayBuffer[, byteOffset[, length]])
- 创建一个封装给定arrayBuffer
的Buffer
。Buffer.from(buffer)
: 创建一个复制buffer
的Buffer
。Buffer.from(string[, encoding])
: 创建一个复制string
的Buffer
。
如果没有 --pending-deprecation
,运行时警告只会出现在不在 node_modules
中的代码中。 这意味着在依赖项中使用 Buffer()
不会有弃用警告。 对于 --pending-deprecation
,无论在何处使用 Buffer()
,都会产生运行时警告。
DEP0006:child_process
options.customFds
#
类型: 生命结束
在 child_process
模块的 spawn()
、fork()
和 exec()
方法中,不推荐使用 options.customFds
选项。 应该改用 options.stdio
选项。
DEP0007:用 worker.exitedAfterDisconnect
替换 cluster
worker.suicide
#
类型: 生命结束
在早期版本的 Node.js cluster
中,名称为 suicide
的布尔属性被添加到 Worker
对象。 此属性的目的是提供有关 Worker
实例退出的方式和原因的指示。 在 Node.js 6.0.0 中,旧属性已弃用并替换为新的 worker.exitedAfterDisconnect
属性。 旧的属性名称并没有准确描述实际的语义,而且不必要地充满了情感。
DEP0008:require('node:constants')
#
类型: 仅文档
node:constants
模块已弃用。 当需要访问与特定 Node.js 内置模块相关的常量时,开发人员应改为引用相关模块公开的 constants
属性。 例如,require('node:fs').constants
和 require('node:os').constants
。
DEP0009:没有摘要的 crypto.pbkdf2
#
类型: 生命结束
在 Node.js 6.0 中不推荐在不指定摘要的情况下使用 crypto.pbkdf2()
API,因为该方法默认使用不推荐的 'SHA1'
摘要。 以前,打印了弃用警告。 从 Node.js 8.0.0 开始,调用 crypto.pbkdf2()
或 crypto.pbkdf2Sync()
并将 digest
设置为 undefined
将抛出 TypeError
。
从 Node.js v11.0.0 开始,在 digest
设置为 null
的情况下调用这些函数将打印弃用警告,以与 digest
为 undefined
时的行为保持一致。
然而现在,传递 undefined
或 null
将抛出 TypeError
。
DEP0010:crypto.createCredentials
#
类型: 生命结束
crypto.createCredentials()
API 已删除。 请改用 tls.createSecureContext()
。
DEP0011:crypto.Credentials
#
类型: 生命结束
crypto.Credentials
类已删除。 请改用 tls.SecureContext
。
DEP0012:Domain.dispose
#
类型: 生命结束
Domain.dispose()
已被删除。 而是通过在域上设置的错误事件处理程序显式地从失败的 I/O 操作中恢复。
DEP0013:没有回调的 fs
异步函数#
类型: 生命结束
在 Node.js 10.0.0 及更高版本中调用不带回调的异步函数会抛出 TypeError
。 参见 https://github.com/nodejs/node/pull/12562。
DEP0014:fs.read
旧版字符串接口#
类型: 生命结束
fs.read()
旧版 String
接口已弃用。 请改用文档中提到的 Buffer
API。
DEP0015:fs.readSync
旧版字符串接口#
类型: 生命结束
fs.readSync()
旧版 String
接口已弃用。 请改用文档中提到的 Buffer
API。
DEP0016:GLOBAL
/root
#
类型: 生命结束
global
属性的 GLOBAL
和 root
别名在 Node.js 6.0.0 中已弃用,此后已被删除。
DEP0017:Intl.v8BreakIterator
#
类型: 生命结束
Intl.v8BreakIterator
是非标准的扩展,已被删除。
参见 Intl.Segmenter
。
DEP0018:未处理的 promise 拒绝#
类型: 生命结束
未处理的promise拒绝已弃用。 默认情况下,未处理的promise拒绝会以非零退出代码终止 Node.js 进程。 要更改 Node.js 处理未处理拒绝的方式,请使用 --unhandled-rejections
命令行选项。
DEP0019:require('.')
在外部目录中解析#
类型: 生命结束
在某些情况下,require('.')
可以在包目录之外解析。
此行为已被删除。
DEP0020:Server.connections
#
类型: 生命结束
Server.connections
属性在 Node.js v0.9.7 中已弃用并已被删除。 请改用 Server.getConnections()
方法。
DEP0021:Server.listenFD
#
类型: 生命结束
Server.listenFD()
方法已弃用并删除。 请改用 Server.listen({fd: <number>})
。
DEP0022:os.tmpDir()
#
类型: 生命结束
os.tmpDir()
API 在 Node.js 7.0.0 中被弃用,并已被删除。 请改用 os.tmpdir()
。
DEP0023:os.getNetworkInterfaces()
#
类型: 生命结束
os.getNetworkInterfaces()
方法已弃用。 请改用 os.networkInterfaces()
方法。
DEP0024:REPLServer.prototype.convertToContext()
#
类型: 生命结束
REPLServer.prototype.convertToContext()
API 已被删除。
DEP0025:require('node:sys')
#
类型: 运行时
node:sys
模块已弃用。 请改用 util
模块。
DEP0026:util.print()
#
类型: 生命结束
util.print()
已被删除。 请改用 console.log()
。
DEP0027:util.puts()
#
类型: 生命结束
util.puts()
已被删除。 请改用 console.log()
。
DEP0028:util.debug()
#
类型: 生命结束
util.debug()
已被删除。 请改用 console.error()
。
DEP0029:util.error()
#
类型: 生命结束
util.error()
已被删除。 请改用 console.error()
。
DEP0030:SlowBuffer
#
类型: 仅文档
SlowBuffer
类已弃用。 请改用 Buffer.allocUnsafeSlow(size)
。
DEP0031:ecdh.setPublicKey()
#
类型: 仅文档
ecdh.setPublicKey()
方法现已弃用,因为它包含在 API 中没有用处。
DEP0032:node:domain
模块#
类型: 仅文档
domain
模块已弃用,不应使用。
DEP0033:EventEmitter.listenerCount()
#
类型: 仅文档
events.listenerCount(emitter, eventName)
API 已弃用。 请改用 emitter.listenerCount(eventName)
。
DEP0034:fs.exists(path, callback)
#
类型: 仅文档
fs.exists(path, callback)
API 已弃用。 请改用 fs.stat()
或 fs.access()
。
DEP0035:fs.lchmod(path, mode, callback)
#
类型: 仅文档
fs.lchmod(path, mode, callback)
API 已弃用。
DEP0036:fs.lchmodSync(path, mode)
#
类型: 仅文档
fs.lchmodSync(path, mode)
API 已弃用。
DEP0037:fs.lchown(path, uid, gid, callback)
#
类型: 撤销弃用
fs.lchown(path, uid, gid, callback)
API 已弃用。 由于在 libuv 中添加了必需的支持 API,因此弃用已被撤销。
DEP0038:fs.lchownSync(path, uid, gid)
#
类型: 撤销弃用
fs.lchownSync(path, uid, gid)
API 已弃用。 由于在 libuv 中添加了必需的支持 API,因此弃用已被撤销。
DEP0039:require.extensions
#
类型: 仅文档
require.extensions
属性已弃用。
DEP0040:node:punycode
模块#
类型: 仅文档(支持 --pending-deprecation
)
punycode
模块已弃用。 请改用用户空间替代方案。
DEP0041:NODE_REPL_HISTORY_FILE
环境变量#
类型: 生命结束
NODE_REPL_HISTORY_FILE
环境变量已删除。 请改用 NODE_REPL_HISTORY
。
DEP0042:tls.CryptoStream
#
类型: 生命结束
tls.CryptoStream
类已删除。 请改用 tls.TLSSocket
。
DEP0043:tls.SecurePair
#
类型: 仅文档
tls.SecurePair
类已弃用。 请改用 tls.TLSSocket
。
DEP0044:util.isArray()
#
类型: 仅文档
util.isArray()
API 已弃用。 请改用 Array.isArray()
。
DEP0045:util.isBoolean()
#
类型: 仅文档
util.isBoolean()
API 已弃用。
DEP0046:util.isBuffer()
#
类型: 仅文档
util.isBuffer()
API 已弃用。 请改用 Buffer.isBuffer()
。
DEP0047:util.isDate()
#
类型: 仅文档
util.isDate()
API 已弃用。
DEP0048:util.isError()
#
类型: 仅文档
util.isError()
API 已弃用。
DEP0049:util.isFunction()
#
类型: 仅文档
util.isFunction()
API 已弃用。
DEP0050:util.isNull()
#
类型: 仅文档
util.isNull()
API 已弃用。
DEP0051:util.isNullOrUndefined()
#
类型: 仅文档
util.isNullOrUndefined()
API 已弃用。
DEP0052:util.isNumber()
#
类型: 仅文档
util.isNumber()
API 已弃用。
DEP0053:util.isObject()
#
类型: 仅文档
util.isObject()
API 已弃用。
DEP0054:util.isPrimitive()
#
类型: 仅文档
util.isPrimitive()
API 已弃用。
DEP0055:util.isRegExp()
#
类型: 仅文档
util.isRegExp()
API 已弃用。
DEP0056:util.isString()
#
类型: 仅文档
util.isString()
API 已弃用。
DEP0057:util.isSymbol()
#
类型: 仅文档
util.isSymbol()
API 已弃用。
DEP0058:util.isUndefined()
#
类型: 仅文档
util.isUndefined()
API 已弃用。
DEP0059:util.log()
#
类型: 仅文档
util.log()
API 已弃用。
DEP0060:util._extend()
#
类型: 仅文档
util._extend()
API 已弃用。
DEP0061:fs.SyncWriteStream
#
类型: 生命结束
fs.SyncWriteStream
类从未打算成为可公开访问的 API,因此已被删除。 没有可用的替代 API。 请使用用户空间替代方案。
DEP0062:node --debug
#
类型: 生命结束
--debug
激活旧版的 V8 调试器接口,该接口从 V8 5.8 开始被删除。 它被 Inspector 取代,后者由 --inspect
激活。
DEP0063:ServerResponse.prototype.writeHeader()
#
类型: 仅文档
node:http
模块 ServerResponse.prototype.writeHeader()
API 已弃用。 请改用 ServerResponse.prototype.writeHead()
。
ServerResponse.prototype.writeHeader()
方法从未被记录为官方支持的 API。
DEP0064:tls.createSecurePair()
#
类型: 运行时
tls.createSecurePair()
API 在 Node.js 0.11.3 的文档中被弃用。 用户应该改用 tls.Socket
。
DEP0065:repl.REPL_MODE_MAGIC
和 NODE_REPL_MODE=magic
#
类型: 生命结束
用于 replMode
选项的 node:repl
模块的 REPL_MODE_MAGIC
常量已被删除。 从 Node.js 6.0.0 开始,当导入 V8 5.0 时,它的行为在功能上与 REPL_MODE_SLOPPY
相同。 请改用 REPL_MODE_SLOPPY
。
NODE_REPL_MODE
环境变量用于设置交互式 node
会话的底层 replMode
。 它的值 magic
也被删除。 请改用 sloppy
。
DEP0066:OutgoingMessage.prototype._headers, OutgoingMessage.prototype._headerNames
#
类型: 运行时
node:http
模块 OutgoingMessage.prototype._headers
和 OutgoingMessage.prototype._headerNames
属性已弃用。 使用一种公共方法(例如 OutgoingMessage.prototype.getHeader()
、OutgoingMessage.prototype.getHeaders()
、OutgoingMessage.prototype.getHeaderNames()
、OutgoingMessage.prototype.getRawHeaderNames()
、OutgoingMessage.prototype.hasHeader()
、OutgoingMessage.prototype.removeHeader()
、OutgoingMessage.prototype.setHeader()
)处理传出标头。
OutgoingMessage.prototype._headers
和 OutgoingMessage.prototype._headerNames
属性从未被记录为官方支持的属性。
DEP0067:OutgoingMessage.prototype._renderHeaders
#
类型: 仅文档
node:http
模块 OutgoingMessage.prototype._renderHeaders()
API 已弃用。
OutgoingMessage.prototype._renderHeaders
属性从未被记录为官方支持的 API。
DEP0068:node debug
#
类型: 生命结束
node debug
对应于旧版的命令行调试器,它已被替换为可通过 node inspect
获得的基于 V8 检查器的命令行调试器。
DEP0069:vm.runInDebugContext(string)
#
类型: 生命结束
DebugContext 已在 V8 中删除,在 Node.js 10+ 中不可用。
DebugContext 是一个实验性 API。
DEP0070:async_hooks.currentId()
#
类型: 生命结束
为清楚起见,async_hooks.currentId()
已重命名为 async_hooks.executionAsyncId()
。
此更改是在 async_hooks
是实验性 API 时进行的。
DEP0071:async_hooks.triggerId()
#
类型: 生命结束
为清楚起见,async_hooks.triggerId()
已重命名为 async_hooks.triggerAsyncId()
。
此更改是在 async_hooks
是实验性 API 时进行的。
DEP0072:async_hooks.AsyncResource.triggerId()
#
类型: 生命结束
为清楚起见,async_hooks.AsyncResource.triggerId()
已重命名为 async_hooks.AsyncResource.triggerAsyncId()
。
此更改是在 async_hooks
是实验性 API 时进行的。
DEP0073:net.Server
的几个内部属性#
类型: 生命结束
使用不适当的名称访问 net.Server
实例的多个内部未记录属性已被弃用。
由于原始 API 未记录且通常对非内部代码没有用,因此未提供替代 API。
DEP0074:REPLServer.bufferedCommand
#
类型: 生命结束
REPLServer.bufferedCommand
属性已弃用,取而代之的是 REPLServer.clearBufferedCommand()
。
DEP0075:REPLServer.parseREPLKeyword()
#
类型: 生命结束
REPLServer.parseREPLKeyword()
已从用户空间可见性中删除。
DEP0076:tls.parseCertString()
#
类型: 生命结束
tls.parseCertString()
是一个简单的解析助手,被错误地公开了。 虽然它应该解析证书主题和颁发者字符串,但它从未正确处理多值相对可分辨名称。
本文档的早期版本建议使用 querystring.parse()
作为 tls.parseCertString()
的替代方法。 但是,querystring.parse()
也没有正确处理所有证书主题,因此不应使用。
DEP0077:Module._debug()
#
类型: 运行时
Module._debug()
已弃用。
Module._debug()
函数从未被记录为官方支持的 API。
DEP0078:REPLServer.turnOffEditorMode()
#
类型: 生命结束
REPLServer.turnOffEditorMode()
已从用户空间可见性中删除。
DEP0079:通过 .inspect()
对对象的自定义检查函数#
类型: 生命结束
不推荐使用对象上名为 inspect
的属性来指定 util.inspect()
的自定义检查函数。 改用 util.inspect.custom
。 为了与版本 6.4.0 之前的 Node.js 向后兼容,可以指定两者。
DEP0080:path._makeLong()
#
类型: 仅文档
内部 path._makeLong()
不供公众使用。 但是,userland 模块发现它很有用。 内部 API 已弃用并替换为相同的公共 path.toNamespacedPath()
方法。
DEP0081:fs.truncate()
使用文件描述符#
类型: 运行时
fs.truncate()
fs.truncateSync()
使用文件描述符已被弃用。 请使用 fs.ftruncate()
或 fs.ftruncateSync()
来处理文件描述符。
DEP0082:REPLServer.prototype.memory()
#
类型: 生命结束
REPLServer.prototype.memory()
只对 REPLServer
本身的内部机制是必需的。 不要使用此功能。
DEP0083:通过将 ecdhCurve
设置为 false
来禁用 ECDH#
类型: 生命尽头。
tls.createSecureContext()
和 tls.TLSSocket
的 ecdhCurve
选项可以设置为 false
以仅在服务器上完全禁用 ECDH。 为了准备迁移到 OpenSSL 1.1.0 并与客户端保持一致,此模式已被弃用,现在不受支持。 请改用 ciphers
参数。
DEP0084:需要捆绑的内部依赖项#
类型: 生命结束
自 Node.js 4.4.0 和 5.2.0 版本以来,几个仅供内部使用的模块通过 require()
错误地暴露给用户代码。 这些模块是:
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()
导入它们的合法用例。
另一方面,node-inspect
可以通过包管理器在本地安装,因为它以相同的名称发布在 npm 注册表上。 如果完成,则无需修改源代码。
DEP0085:AsyncHooks 敏感 API#
类型: 生命结束
AsyncHooks 敏感 API 从未记录在案,并且存在各种小问题。
改用 AsyncResource
API。 参见 https://github.com/nodejs/node/issues/15572。
DEP0086:删除 runInAsyncIdScope
#
类型: 生命结束
runInAsyncIdScope
不会触发 'before'
或 'after'
事件,因此会导致很多问题。 参见 https://github.com/nodejs/node/issues/14328。
DEP0089:require('node:assert')
#
类型: 撤销弃用
不建议直接导入断言,因为公开的函数使用松散的相等性检查。 由于不鼓励使用 node:assert
模块,因此弃用被撤销,并且弃用导致开发人员感到困惑。
DEP0090:无效的 GCM 身份验证标签长度#
类型: 生命结束
Node.js 用于支持调用 decipher.setAuthTag()
时 OpenSSL 接受的所有 GCM 身份验证标记长度。 从 Node.js v11.0.0 开始,只允许 128、120、112、104、96、64 和 32 位的身份验证标记长度。 根据 NIST SP 800-38D,其他长度的身份验证标签无效。
DEP0091:crypto.DEFAULT_ENCODING
#
类型: 运行时
crypto.DEFAULT_ENCODING
属性已弃用。
DEP0092:顶层 this
绑定到 module.exports
#
类型: 仅文档
将属性分配给顶层 this
作为 module.exports
的替代方案已被弃用。 开发人员应改用 exports
或 module.exports
。
DEP0093:crypto.fips
已弃用并被替换#
类型: 仅文档
crypto.fips
属性已弃用。 请改用 crypto.setFips()
和 crypto.getFips()
。
DEP0094:将 assert.fail()
与多个参数一起使用#
类型: 运行时
不推荐将 assert.fail()
与多个参数一起使用。 使用只有一个参数的 assert.fail()
或使用不同的 node:assert
模块方法。
DEP0095:timers.enroll()
#
类型: 运行时
timers.enroll()
已弃用。 请改用公开记录的 setTimeout()
或 setInterval()
。
DEP0096:timers.unenroll()
#
类型: 运行时
timers.unenroll()
已弃用。 请改用公开记录的 clearTimeout()
或 clearInterval()
。
DEP0097:具有 domain
属性的 MakeCallback
#
类型: 运行时
添加 domain
属性以承载上下文的 MakeCallback
用户应开始使用 MakeCallback
或 CallbackScope
的 async_context
变体,或高级 AsyncResource
类。
DEP0098:AsyncHooks 嵌入器 AsyncResource.emitBefore
和 AsyncResource.emitAfter
API#
类型: 生命结束
AsyncHooks 提供的嵌入式 API 公开了 .emitBefore()
和 .emitAfter()
方法,这些方法很容易被错误使用,从而导致不可恢复的错误。
请改用 asyncResource.runInAsyncScope()
API,它提供了更安全、更方便的替代方案。 参见 https://github.com/nodejs/node/pull/18513。
DEP0099:异步上下文不感知的 node::MakeCallback
C++ API#
类型: 编译时
可用于原生插件的某些版本的 node::MakeCallback
API 已弃用。 请使用接受 async_context
参数的 API 版本。
DEP0100:process.assert()
#
类型: 运行时
process.assert()
已弃用。 请改用 assert
模块。
这从来都不是记录在案的功能。
DEP0101:--with-lttng
#
类型: 生命结束
--with-lttng
编译时选项已被删除。
DEP0102:在 Buffer#(read|write)
操作中使用 noAssert
#
类型: 生命结束
使用 noAssert
参数不再起作用。 无论 noAssert
的值如何,都会验证所有输入。 跳过验证可能会导致难以发现的错误和崩溃。
DEP0103:process.binding('util').is[...]
类型检查#
类型: 仅文档(支持 --pending-deprecation
)
通常应避免使用 process.binding()
。 特别是类型检查方法可以用 util.types
代替。
此弃用已被 process.binding()
API (DEP0111) 的弃用所取代。
DEP0104:process.env
字符串强制转换#
类型: 仅文档(支持 --pending-deprecation
)
将非字符串属性分配给 process.env
时,分配的值将隐式转换为字符串。 如果分配的值不是字符串、布尔值或数字,则不推荐使用此行为。 将来,这样的分配可能会导致抛出错误。 请先将该属性转换为字符串,然后再将其分配给 process.env
。
DEP0105:decipher.finaltol
#
类型: 生命结束
decipher.finaltol()
从未被记录,它是 decipher.final()
的别名。 此API已被移除,建议改用decipher.final()
。
DEP0106:crypto.createCipher
和 crypto.createDecipher
#
类型: 运行时
必须避免使用 crypto.createCipher()
和 crypto.createDecipher()
,因为它们使用弱密钥派生函数(无盐的 MD5)和静态初始化向量。 建议使用 crypto.pbkdf2()
或 crypto.scrypt()
和随机盐派生密钥,并使用 crypto.createCipheriv()
和 crypto.createDecipheriv()
分别获得 Cipher
和 Decipher
对象。
DEP0107:tls.convertNPNProtocols()
#
类型: 生命结束
这是一个未记录的辅助函数,不打算在 Node.js 核心之外使用,并因删除 NPN(下一个协议协商)支持而被废弃。
DEP0108:zlib.bytesRead
#
类型: 运行时
弃用的 zlib.bytesWritten
别名。 选择这个原始名称是因为将值解释为引擎读取的字节数也是有意义的,但与 Node.js 中以这些名称公开值的其他流不一致。
DEP0109:http
、https
和 tls
支持无效 URL#
类型: 生命结束
通过 http.request()
、http.get()
、https.request()
、https.get()
和 tls.checkServerIdentity()
API 接受了一些以前支持(但严格无效)的 URL,因为这些 URL 已被旧版 url.parse()
API 接受。 上述 API 现在使用要求严格有效 URL 的 WHATWG URL 解析器。 传递无效的 URL 已被弃用,将来会删除支持。
DEP0110:vm.Script
缓存数据#
类型: 仅文档
produceCachedData
选项已弃用。 改用 script.createCachedData()
。
DEP0111:process.binding()
#
类型: 仅文档(支持 --pending-deprecation
)
process.binding()
仅供 Node.js 内部代码使用。
DEP0112:dgram
私有 API#
类型: 运行时
node:dgram
模块以前包含几个 API,这些 API 永远不会在 Node.js 核心之外访问: Socket.prototype._handle
、Socket.prototype._receiving
、Socket.prototype._bindState
、Socket.prototype._queue
、Socket.prototype._reuseAddr
、Socket.prototype._healthCheck()
、Socket.prototype._stopReceiving()
和 dgram._createSocketHandle()
。
DEP0113:Cipher.setAuthTag()
,Decipher.getAuthTag()
#
类型: 生命结束
Cipher.setAuthTag()
和 Decipher.getAuthTag()
不再可用。 他们从未被记录在案,并且会在被调用时抛出。
DEP0114:crypto._toBuf()
#
类型: 生命结束
crypto._toBuf()
函数并非设计为供 Node.js 核心之外的模块使用,因此已被删除。
DEP0115:crypto.prng()
、crypto.pseudoRandomBytes()
、crypto.rng()
#
类型: 仅文档(支持 --pending-deprecation
)
在最近的 Node.js 版本中,crypto.randomBytes()
和 crypto.pseudoRandomBytes()
之间没有区别。 后者与未记录的别名 crypto.prng()
和 crypto.rng()
一起被弃用,取而代之的是 crypto.randomBytes()
,并且可能会在未来的版本中删除。
DEP0116:旧版 URL API#
类型: 撤销弃用
旧版 URL API 已弃用。 这包括 url.format()
、url.parse()
、url.resolve()
和 旧版 urlObject
。 请改用 WHATWG URL API。
DEP0117:原生加密句柄#
类型: 生命结束
以前版本的 Node.js 通过 Cipher
、Decipher
、DiffieHellman
、DiffieHellmanGroup
、ECDH
、Hash
、Hmac
、Sign
和 Verify
类的 _handle
属性向内部原生对象公开句柄。
_handle
属性已被删除,因为不正确地使用原生对象会导致应用程序崩溃。
DEP0118:dns.lookup()
支持虚假主机名#
类型: 运行时
由于向后兼容,以前版本的 Node.js 支持 dns.lookup()
和像 dns.lookup(false)
这样的虚假主机名。
此行为未记录在案,并且被认为未在现实世界的应用程序中使用。
它将成为 Node.js 未来版本中的一个错误。
DEP0119:process.binding('uv').errname()
私有 API#
类型: 仅文档(支持 --pending-deprecation
)
process.binding('uv').errname()
已弃用。 请改用 util.getSystemErrorName()
。
DEP0120:Windows 性能计数器支持#
类型: 生命结束
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()
函数已被弃用。
DEP0121:net._setSimultaneousAccepts()
#
类型: 运行时
未记录的 net._setSimultaneousAccepts()
函数最初用于在 Windows 上使用 node:child_process
和 node:cluster
模块时进行调试和性能调整。 该功能通常用处不大,正在被删除。 请参阅此处的讨论:
https://github.com/nodejs/node/issues/18391
DEP0122:tls
Server.prototype.setOptions()
#
类型: 运行时
请改用 Server.prototype.setSecureContext()
。
DEP0123:将 TLS ServerName 设置为 IP 地址#
类型: 运行时
RFC 6066 不允许将 TLS ServerName 设置为 IP 地址。 这将在未来的版本中被忽略。
DEP0124:使用 REPLServer.rli
#
类型: 生命结束
此属性是对实例本身的引用。
DEP0125:require('node:_stream_wrap')
#
类型: 运行时
node:_stream_wrap
模块已弃用。
DEP0126:timers.active()
#
类型: 运行时
以前未记录的 timers.active()
已弃用。
请改用公开记录的 timeout.refresh()
。
如果需要重新引用超时,自 Node.js 10 起可以使用 timeout.ref()
而不会影响性能。
DEP0127:timers._unrefActive()
#
类型: 运行时
以前未记录的和 "private" timers._unrefActive()
已弃用。
请改用公开记录的 timeout.refresh()
。
如果需要取消引用超时,自 Node.js 10 起可以使用 timeout.unref()
而不会影响性能。
DEP0128:具有无效 main
条目和 index.js
文件的模块#
类型: 运行时
具有无效 main
条目(例如,./does-not-exist.js
)并且在顶层目录中也具有 index.js
文件的模块将解析 index.js
文件。 这已被弃用,并且会在未来的 Node.js 版本中引发错误。
DEP0129:ChildProcess._channel
#
类型: 运行时
spawn()
和类似函数返回的子进程对象的 _channel
属性不供公共使用。 改用 ChildProcess.channel
。
DEP0130:Module.createRequireFromPath()
#
类型: 生命结束
DEP0131:旧版 HTTP 解析器#
类型: 生命结束
在 12.0.0 之前的 Node.js 版本中默认使用的旧版 HTTP 解析器已弃用,并已在 v13.0.0 中删除。 在 v13.0.0 之前,--http-parser=legacy
命令行标志可用于恢复使用旧版解析器。
DEP0132:带有回调的 worker.terminate()
#
类型: 运行时
将回调传递给 worker.terminate()
已弃用。 请改用返回的 Promise
,或监听工作人员的 'exit'
事件。
DEP0133:http
connection
#
类型: 仅文档
比 response.connection
更喜欢 response.socket
,比 request.connection
更喜欢 request.socket
。
DEP0134:process._tickCallback
#
类型: 仅文档(支持 --pending-deprecation
)
process._tickCallback
属性从未被记录为官方支持的 API。
DEP0135:WriteStream.open()
和 ReadStream.open()
是内部的#
类型: 运行时
WriteStream.open()
和 ReadStream.open()
是未记录的内部 API,在用户空间中使用没有意义。 文件流应始终通过其相应的工厂方法 fs.createWriteStream()
和 fs.createReadStream()
) 或通过在选项中传递文件描述符来打开。
DEP0136:http
finished
#
类型: 仅文档
response.finished
表示 response.end()
是否已被调用,而不是 'finish'
是否已触发并刷新底层数据。
相应地使用 response.writableFinished
或 response.writableEnded
以避免歧义。
为保持现有行为,response.finished
应替换为 response.writableEnded
。
DEP0137:在垃圾回收时关闭 fs.FileHandle#
类型: 运行时
允许在垃圾回收时关闭 fs.FileHandle
对象已弃用。 将来,这样做可能会导致抛出错误,从而终止进程。
请确保在不再需要 fs.FileHandle
时使用 FileHandle.prototype.close()
显式关闭所有 fs.FileHandle
对象:
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
#
类型: 仅文档
process.mainModule
是 CommonJS 独有的特性,而 process
全局对象与非 CommonJS 环境共享。 不支持在 ECMAScript 模块中使用它。
它已被弃用,取而代之的是 require.main
,因为它具有相同的目的并且仅在 CommonJS 环境中可用。
DEP0139:没有参数的 process.umask()
#
类型: 仅文档
不带参数调用 process.umask()
会导致进程范围的 umask 被写入两次。 这在线程之间引入了竞争条件,并且是一个潜在的安全漏洞。 没有安全的、跨平台的替代 API。
DEP0140:使用 request.destroy()
而不是 request.abort()
#
类型: 仅文档
使用 request.destroy()
而不是 request.abort()
。
DEP0141:repl.inputStream
和 repl.outputStream
#
类型: 仅文档(支持 --pending-deprecation
)
node:repl
模块两次导出输入输出流。 使用 .input
代替 .inputStream
,使用 .output
代替 .outputStream
。
DEP0142:repl._builtinLibs
#
类型: 仅文档
node:repl
模块导出一个包含内置模块数组的 _builtinLibs
属性。 到目前为止它还不完整,最好依赖 require('node:module').builtinModules
。
DEP0143:Transform._transformState
#
类型: Runtime Transform._transformState
将在以后的版本中删除,因为实现的简化不再需要它。
DEP0144:module.parent
#
类型: 仅文档(支持 --pending-deprecation
)
CommonJS 模块可以使用 module.parent
访问需要它的第一个模块。 此功能已被弃用,因为它在存在 ECMAScript 模块的情况下无法始终如一地工作,并且因为它给出了 CommonJS 模块图的不准确表示。
一些模块使用它来检查它们是否是当前进程的入口点。
相反,建议比较 require.main
和 module
:
if (require.main === module) {
// Code section that will run only if current file is the entry point.
}
在查找需要当前模块的 CommonJS 模块时,可以使用 require.cache
和 module.children
:
const moduleParents = Object.values(require.cache)
.filter((m) => m.children.includes(module));
DEP0145:socket.bufferSize
#
类型: 仅文档
socket.bufferSize
只是 writable.writableLength
的别名。
DEP0146:new crypto.Certificate()
#
类型: 仅文档
crypto.Certificate()
构造函数 已弃用。 改用 crypto.Certificate()
的静态方法。
DEP0147:fs.rmdir(path, { recursive: true })
#
类型: 运行时
在 Node.js 的未来版本中,fs.rmdir
、fs.rmdirSync
和 fs.promises.rmdir
将忽略 recursive
选项。
请改用 fs.rm(path, { recursive: true, force: true })
、fs.rmSync(path, { recursive: true, force: true })
或 fs.promises.rm(path, { recursive: true, force: true })
。
DEP0148:"exports"
中的文件夹映射(尾随 "/"
)#
类型: 运行时
使用尾随 "/"
在 子路径导出 或 子路径导入 字段中定义子路径文件夹映射已被弃用。 改用 子路径模式。
DEP0149:http.IncomingMessage#connection
#
类型: 仅文档。
比 message.connection
更喜欢 message.socket
。
DEP0150:更改 process.config
的值#
类型: 生命结束
process.config
属性提供对 Node.js 编译时设置的访问。
但是,该属性是可变的,因此容易被篡改。 更改值的功能将在 Node.js 的未来版本中删除。
DEP0151:主索引查找和扩展搜索#
类型: 运行时
以前,index.js
和扩展搜索查找将应用于 import 'pkg'
主入口点解析,即使在解析 ES 模块时也是如此。
通过此弃用,所有 ES 模块主入口点解析都需要具有确切文件扩展名的显式 "exports"
或 "main"
条目。
DEP0152:扩展 PerformanceEntry 属性#
类型: 运行时
'gc'
、'http2'
和 'http'
<PerformanceEntry> 对象类型具有分配给它们的附加属性以提供附加信息。
这些属性现在在 PerformanceEntry
对象的标准 detail
属性中可用。 现有访问器已被弃用,不应再使用。
DEP0153:dns.lookup
和 dnsPromises.lookup
选项类型强制转换#
类型: 生命结束
对 family
选项使用非无效非整数值,对 hints
选项使用非无效非数字值,对 all
选项使用非无效非布尔值,或对 verbatim
选项使用非无效非布尔值 dns.lookup()
和 dnsPromises.lookup()
引发 ERR_INVALID_ARG_TYPE
错误。
DEP0154:RSA-PSS 生成密钥对选项#
类型: 仅文档(支持 --pending-deprecation
)
'hash'
和 'mgf1Hash'
选项已替换为 'hashAlgorithm'
和 'mgf1HashAlgorithm'
。
DEP0155:模式说明符解析中的尾部斜线#
类型: 运行时
对于包 "exports"
和 "imports"
模式解析,不推荐重新映射以 "/"
结尾的说明符(如 import 'pkg/x/'
)。
DEP0156:http
中的 .aborted
属性和 'abort'
、'aborted'
事件#
类型: 仅文档
改用 <Stream> API,因为 http.ClientRequest
、http.ServerResponse
和 http.IncomingMessage
都是基于流的。
检查 stream.destroyed
而不是 .aborted
属性,并监听 'close'
而不是 'abort'
、'aborted'
事件。
.aborted
属性和 'abort'
事件仅对检测 .abort()
调用有用。 要提前关闭请求,请使用 Stream .destroy([error])
,然后检查 .destroyed
属性和 'close'
事件应该具有相同的效果。 接收端还应该检查 http.IncomingMessage
上的 readable.readableEnded
值,以确定它是中止的还是正常的销毁。
DEP0157:流中的 Thenable 支持#
类型: 生命结束
Node.js 流的一个未记录的特性是在实现方法中支持 thenables。 现在已弃用,请改用回调并避免对流实现方法使用异步函数。
此功能导致用户遇到意想不到的问题,即用户以回调方式实现功能但使用例如 一个会导致错误的异步方法,因为混合 promise 和回调语义是无效的。
const w = new Writable({
async final(callback) {
await someOp();
callback();
},
});
DEP0158:buffer.slice(start, end)
#
类型: 仅文档
此方法已被弃用,因为它与 Uint8Array.prototype.slice()
不兼容,Uint8Array.prototype.slice()
是 Buffer
的超类。
使用 buffer.subarray
来代替做同样的事情。
DEP0159:ERR_INVALID_CALLBACK
#
类型: 生命结束
由于对用于值类型验证的错误增加了更多混淆,因此删除了此错误代码。
DEP0160:process.on('multipleResolves', handler)
#
类型: 运行。
此事件已弃用,因为它不适用于 V8 promise 组合器,这降低了它的用处。
DEP0161:process._getActiveRequests()
和 process._getActiveHandles()
#
类型: 仅文档
process._getActiveHandles()
和 process._getActiveRequests()
函数不供公众使用,可以在未来的版本中删除。
使用 process.getActiveResourcesInfo()
获取活动资源类型列表,而不是实际引用。
DEP0162:fs.write()
、fs.writeFileSync()
强制转换为字符串#
类型: 生命结束
不推荐使用 fs.write()
、fs.writeFile()
、fs.appendFile()
、fs.writeFileSync()
和 fs.appendFileSync()
中作为第二个参数传递的具有自己的 toString
属性的对象的隐式强制转换。
将它们转换为原始字符串。
DEP0163:channel.subscribe(onMessage)
,channel.unsubscribe(onMessage)
#
类型: 仅文档
这些方法已被弃用,因为它们的使用方式不会使通道引用保持足够长的时间以接收事件。
使用做同样事情的 diagnostics_channel.subscribe(name, onMessage)
或 diagnostics_channel.unsubscribe(name, onMessage)
。
DEP0164:process.exit(code)
、process.exitCode
强制转换为整数#
类型: 仅文档
undefined
、null
、整数和整数字符串(例如,'1'
)以外的值作为 process.exit()
中 code
参数的值以及分配给 process.exitCode
的值已弃用。
DEP0165:--trace-atomics-wait
#
类型: 仅文档
--trace-atomics-wait
标志已弃用。
DEP0166:导入导出目标中的双斜线#
类型: 运行时
映射到包含双斜杠("/" 或 "\")的路径的包导入和导出目标已弃用,并且在未来的版本中将失败并出现解析验证错误。 同样的弃用也适用于以斜杠开头或结尾的模式匹配。
DEP0167:弱 DiffieHellmanGroup
实例(modp1
、modp2
、modp5
)#
类型: 仅文档
著名的 MODP 组 modp1
、modp2
和 modp5
已弃用,因为它们无法抵御实际攻击。 详见 RFC 8247 第 2.4 节。
这些组可能会在 Node.js 的未来版本中被删除。 依赖这些组的应用程序应该使用更强大的 MODP 组进行评估。
DEP0168:Node-API 回调中未处理的异常#
类型: 运行时
Node-API 回调中未捕获异常的隐式抑制现已弃用。
如果异常未在 Node-API 回调中处理,则设置标志 --force-node-api-uncaught-exceptions-policy
以强制 Node.js 触发 'uncaughtException'
事件。
DEP0169:不安全的 url.parse()#
类型: 仅文档
url.parse()
行为不规范,容易出现具有安全隐患的错误。 请改用 WHATWG URL API。 不针对 url.parse()
漏洞发布 CVE。
DEP0170:使用 url.parse()
时端口无效#
类型: 仅文档
url.parse()
接受端口不是数字的 URL。 此行为可能会导致使用意外输入进行主机名欺骗。 这些 URL 将在未来版本的 Node.js 中抛出错误,就像 WHATWG URL API 已经做的那样。
DEP0171:http.IncomingMessage
标头和尾部的设置器#
类型: 仅文档
在 Node.js 的未来版本中,message.headers
、message.headersDistinct
、message.trailers
和 message.trailersDistinct
将是只读的。