- 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.20.0 文档
- Node.js v18.20.0
-
目录
- 错误
- 错误冒泡和拦截
- 类:
Error
- 类:
AssertionError
- 类:
RangeError
- 类:
ReferenceError
- 类:
SyntaxError
- 类:
SystemError
- 类:
TypeError
- 异常与错误
- OpenSSL 错误
- Node.js 错误代码
ABORT_ERR
ERR_ACCESS_DENIED
ERR_AMBIGUOUS_ARGUMENT
ERR_ARG_NOT_ITERABLE
ERR_ASSERTION
ERR_ASYNC_CALLBACK
ERR_ASYNC_TYPE
ERR_BROTLI_COMPRESSION_FAILED
ERR_BROTLI_INVALID_PARAM
ERR_BUFFER_CONTEXT_NOT_AVAILABLE
ERR_BUFFER_OUT_OF_BOUNDS
ERR_BUFFER_TOO_LARGE
ERR_CANNOT_WATCH_SIGINT
ERR_CHILD_CLOSED_BEFORE_REPLY
ERR_CHILD_PROCESS_IPC_REQUIRED
ERR_CHILD_PROCESS_STDIO_MAXBUFFER
ERR_CLOSED_MESSAGE_PORT
ERR_CONSOLE_WRITABLE_STREAM
ERR_CONSTRUCT_CALL_INVALID
ERR_CONSTRUCT_CALL_REQUIRED
ERR_CONTEXT_NOT_INITIALIZED
ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED
ERR_CRYPTO_ECDH_INVALID_FORMAT
ERR_CRYPTO_ECDH_INVALID_PUBLIC_KEY
ERR_CRYPTO_ENGINE_UNKNOWN
ERR_CRYPTO_FIPS_FORCED
ERR_CRYPTO_FIPS_UNAVAILABLE
ERR_CRYPTO_HASH_FINALIZED
ERR_CRYPTO_HASH_UPDATE_FAILED
ERR_CRYPTO_INCOMPATIBLE_KEY
ERR_CRYPTO_INCOMPATIBLE_KEY_OPTIONS
ERR_CRYPTO_INITIALIZATION_FAILED
ERR_CRYPTO_INVALID_AUTH_TAG
ERR_CRYPTO_INVALID_COUNTER
ERR_CRYPTO_INVALID_CURVE
ERR_CRYPTO_INVALID_DIGEST
ERR_CRYPTO_INVALID_IV
ERR_CRYPTO_INVALID_JWK
ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE
ERR_CRYPTO_INVALID_KEYLEN
ERR_CRYPTO_INVALID_KEYPAIR
ERR_CRYPTO_INVALID_KEYTYPE
ERR_CRYPTO_INVALID_MESSAGELEN
ERR_CRYPTO_INVALID_SCRYPT_PARAMS
ERR_CRYPTO_INVALID_STATE
ERR_CRYPTO_INVALID_TAG_LENGTH
ERR_CRYPTO_JOB_INIT_FAILED
ERR_CRYPTO_JWK_UNSUPPORTED_CURVE
ERR_CRYPTO_JWK_UNSUPPORTED_KEY_TYPE
ERR_CRYPTO_OPERATION_FAILED
ERR_CRYPTO_PBKDF2_ERROR
ERR_CRYPTO_SCRYPT_INVALID_PARAMETER
ERR_CRYPTO_SCRYPT_NOT_SUPPORTED
ERR_CRYPTO_SIGN_KEY_REQUIRED
ERR_CRYPTO_TIMING_SAFE_EQUAL_LENGTH
ERR_CRYPTO_UNKNOWN_CIPHER
ERR_CRYPTO_UNKNOWN_DH_GROUP
ERR_CRYPTO_UNSUPPORTED_OPERATION
ERR_DEBUGGER_ERROR
ERR_DEBUGGER_STARTUP_ERROR
ERR_DLOPEN_DISABLED
ERR_DLOPEN_FAILED
ERR_DIR_CLOSED
ERR_DIR_CONCURRENT_OPERATION
ERR_DNS_SET_SERVERS_FAILED
ERR_DOMAIN_CALLBACK_NOT_AVAILABLE
ERR_DOMAIN_CANNOT_SET_UNCAUGHT_EXCEPTION_CAPTURE
ERR_DUPLICATE_STARTUP_SNAPSHOT_MAIN_FUNCTION
ERR_ENCODING_INVALID_ENCODED_DATA
ERR_ENCODING_NOT_SUPPORTED
ERR_EVAL_ESM_CANNOT_PRINT
ERR_EVENT_RECURSION
ERR_EXECUTION_ENVIRONMENT_NOT_AVAILABLE
ERR_FALSY_VALUE_REJECTION
ERR_FEATURE_UNAVAILABLE_ON_PLATFORM
ERR_FS_CP_DIR_TO_NON_DIR
ERR_FS_CP_EEXIST
ERR_FS_CP_EINVAL
ERR_HTTP_BODY_NOT_ALLOWED
ERR_HTTP_CONTENT_LENGTH_MISMATCH
ERR_FS_CP_FIFO_PIPE
ERR_FS_CP_NON_DIR_TO_DIR
ERR_FS_CP_SOCKET
ERR_FS_CP_SYMLINK_TO_SUBDIRECTORY
ERR_FS_CP_UNKNOWN
ERR_FS_EISDIR
ERR_FS_FILE_TOO_LARGE
ERR_FS_INVALID_SYMLINK_TYPE
ERR_HTTP_HEADERS_SENT
ERR_HTTP_INVALID_HEADER_VALUE
ERR_HTTP_INVALID_STATUS_CODE
ERR_HTTP_REQUEST_TIMEOUT
ERR_HTTP_SOCKET_ASSIGNED
ERR_HTTP_SOCKET_ENCODING
ERR_HTTP_TRAILER_INVALID
ERR_HTTP2_ALTSVC_INVALID_ORIGIN
ERR_HTTP2_ALTSVC_LENGTH
ERR_HTTP2_CONNECT_AUTHORITY
ERR_HTTP2_CONNECT_PATH
ERR_HTTP2_CONNECT_SCHEME
ERR_HTTP2_ERROR
ERR_HTTP2_GOAWAY_SESSION
ERR_HTTP2_HEADER_SINGLE_VALUE
ERR_HTTP2_HEADERS_AFTER_RESPOND
ERR_HTTP2_HEADERS_SENT
ERR_HTTP2_INFO_STATUS_NOT_ALLOWED
ERR_HTTP2_INVALID_CONNECTION_HEADERS
ERR_HTTP2_INVALID_HEADER_VALUE
ERR_HTTP2_INVALID_INFO_STATUS
ERR_HTTP2_INVALID_ORIGIN
ERR_HTTP2_INVALID_PACKED_SETTINGS_LENGTH
ERR_HTTP2_INVALID_PSEUDOHEADER
ERR_HTTP2_INVALID_SESSION
ERR_HTTP2_INVALID_SETTING_VALUE
ERR_HTTP2_INVALID_STREAM
ERR_HTTP2_MAX_PENDING_SETTINGS_ACK
ERR_HTTP2_NESTED_PUSH
ERR_HTTP2_NO_MEM
ERR_HTTP2_NO_SOCKET_MANIPULATION
ERR_HTTP2_ORIGIN_LENGTH
ERR_HTTP2_OUT_OF_STREAMS
ERR_HTTP2_PAYLOAD_FORBIDDEN
ERR_HTTP2_PING_CANCEL
ERR_HTTP2_PING_LENGTH
ERR_HTTP2_PSEUDOHEADER_NOT_ALLOWED
ERR_HTTP2_PUSH_DISABLED
ERR_HTTP2_SEND_FILE
ERR_HTTP2_SEND_FILE_NOSEEK
ERR_HTTP2_SESSION_ERROR
ERR_HTTP2_SETTINGS_CANCEL
ERR_HTTP2_SOCKET_BOUND
ERR_HTTP2_SOCKET_UNBOUND
ERR_HTTP2_STATUS_101
ERR_HTTP2_STATUS_INVALID
ERR_HTTP2_STREAM_CANCEL
ERR_HTTP2_STREAM_ERROR
ERR_HTTP2_STREAM_SELF_DEPENDENCY
ERR_HTTP2_TOO_MANY_INVALID_FRAMES
ERR_HTTP2_TRAILERS_ALREADY_SENT
ERR_HTTP2_TRAILERS_NOT_READY
ERR_HTTP2_UNSUPPORTED_PROTOCOL
ERR_ILLEGAL_CONSTRUCTOR
ERR_IMPORT_ASSERTION_TYPE_FAILED
ERR_IMPORT_ASSERTION_TYPE_MISSING
ERR_IMPORT_ASSERTION_TYPE_UNSUPPORTED
ERR_IMPORT_ATTRIBUTE_UNSUPPORTED
ERR_INCOMPATIBLE_OPTION_PAIR
ERR_INPUT_TYPE_NOT_ALLOWED
ERR_INSPECTOR_ALREADY_ACTIVATED
ERR_INSPECTOR_ALREADY_CONNECTED
ERR_INSPECTOR_CLOSED
ERR_INSPECTOR_COMMAND
ERR_INSPECTOR_NOT_ACTIVE
ERR_INSPECTOR_NOT_AVAILABLE
ERR_INSPECTOR_NOT_CONNECTED
ERR_INSPECTOR_NOT_WORKER
ERR_INTERNAL_ASSERTION
ERR_INVALID_ADDRESS_FAMILY
ERR_INVALID_ARG_TYPE
ERR_INVALID_ARG_VALUE
ERR_INVALID_ASYNC_ID
ERR_INVALID_BUFFER_SIZE
ERR_INVALID_CHAR
ERR_INVALID_CURSOR_POS
ERR_INVALID_FD
ERR_INVALID_FD_TYPE
ERR_INVALID_FILE_URL_HOST
ERR_INVALID_FILE_URL_PATH
ERR_INVALID_HANDLE_TYPE
ERR_INVALID_HTTP_TOKEN
ERR_INVALID_IP_ADDRESS
ERR_INVALID_MIME_SYNTAX
ERR_INVALID_MODULE
ERR_INVALID_MODULE_SPECIFIER
ERR_INVALID_OBJECT_DEFINE_PROPERTY
ERR_INVALID_PACKAGE_CONFIG
ERR_INVALID_PACKAGE_TARGET
ERR_INVALID_PERFORMANCE_MARK
ERR_INVALID_PROTOCOL
ERR_INVALID_REPL_EVAL_CONFIG
ERR_INVALID_REPL_INPUT
ERR_INVALID_RETURN_PROPERTY
ERR_INVALID_RETURN_PROPERTY_VALUE
ERR_INVALID_RETURN_VALUE
ERR_INVALID_STATE
ERR_INVALID_SYNC_FORK_INPUT
ERR_INVALID_THIS
ERR_INVALID_TRANSFER_OBJECT
ERR_INVALID_TUPLE
ERR_INVALID_URI
ERR_INVALID_URL
ERR_INVALID_URL_SCHEME
ERR_IPC_CHANNEL_CLOSED
ERR_IPC_DISCONNECTED
ERR_IPC_ONE_PIPE
ERR_IPC_SYNC_FORK
ERR_LOADER_CHAIN_INCOMPLETE
ERR_MANIFEST_ASSERT_INTEGRITY
ERR_MANIFEST_DEPENDENCY_MISSING
ERR_MANIFEST_INTEGRITY_MISMATCH
ERR_MANIFEST_INVALID_RESOURCE_FIELD
ERR_MANIFEST_INVALID_SPECIFIER
ERR_MANIFEST_PARSE_POLICY
ERR_MANIFEST_TDZ
ERR_MANIFEST_UNKNOWN_ONERROR
ERR_MEMORY_ALLOCATION_FAILED
ERR_MESSAGE_TARGET_CONTEXT_UNAVAILABLE
ERR_METHOD_NOT_IMPLEMENTED
ERR_MISSING_ARGS
ERR_MISSING_OPTION
ERR_MISSING_PASSPHRASE
ERR_MISSING_PLATFORM_FOR_WORKER
ERR_MISSING_TRANSFERABLE_IN_TRANSFER_LIST
ERR_MODULE_NOT_FOUND
ERR_MULTIPLE_CALLBACK
ERR_NAPI_CONS_FUNCTION
ERR_NAPI_INVALID_DATAVIEW_ARGS
ERR_NAPI_INVALID_TYPEDARRAY_ALIGNMENT
ERR_NAPI_INVALID_TYPEDARRAY_LENGTH
ERR_NAPI_TSFN_CALL_JS
ERR_NAPI_TSFN_GET_UNDEFINED
ERR_NAPI_TSFN_START_IDLE_LOOP
ERR_NAPI_TSFN_STOP_IDLE_LOOP
ERR_NOT_BUILDING_SNAPSHOT
ERR_NO_CRYPTO
ERR_NO_ICU
ERR_NON_CONTEXT_AWARE_DISABLED
ERR_OUT_OF_RANGE
ERR_PACKAGE_IMPORT_NOT_DEFINED
ERR_PACKAGE_PATH_NOT_EXPORTED
ERR_PARSE_ARGS_INVALID_OPTION_VALUE
ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL
ERR_PARSE_ARGS_UNKNOWN_OPTION
ERR_PERFORMANCE_INVALID_TIMESTAMP
ERR_PERFORMANCE_MEASURE_INVALID_OPTIONS
ERR_PROTO_ACCESS
ERR_REQUIRE_ESM
ERR_SCRIPT_EXECUTION_INTERRUPTED
ERR_SCRIPT_EXECUTION_TIMEOUT
ERR_SERVER_ALREADY_LISTEN
ERR_SERVER_NOT_RUNNING
ERR_SOCKET_ALREADY_BOUND
ERR_SOCKET_BAD_BUFFER_SIZE
ERR_SOCKET_BAD_PORT
ERR_SOCKET_BAD_TYPE
ERR_SOCKET_BUFFER_SIZE
ERR_SOCKET_CLOSED
ERR_SOCKET_CLOSED_BEFORE_CONNECTION
ERR_SOCKET_DGRAM_IS_CONNECTED
ERR_SOCKET_DGRAM_NOT_CONNECTED
ERR_SOCKET_DGRAM_NOT_RUNNING
ERR_SRI_PARSE
ERR_STREAM_ALREADY_FINISHED
ERR_STREAM_CANNOT_PIPE
ERR_STREAM_DESTROYED
ERR_STREAM_NULL_VALUES
ERR_STREAM_PREMATURE_CLOSE
ERR_STREAM_PUSH_AFTER_EOF
ERR_STREAM_UNSHIFT_AFTER_END_EVENT
ERR_STREAM_WRAP
ERR_STREAM_WRITE_AFTER_END
ERR_STRING_TOO_LONG
ERR_SYNTHETIC
ERR_SYSTEM_ERROR
ERR_TAP_LEXER_ERROR
ERR_TAP_PARSER_ERROR
ERR_TAP_VALIDATION_ERROR
ERR_TEST_FAILURE
ERR_TLS_ALPN_CALLBACK_INVALID_RESULT
ERR_TLS_ALPN_CALLBACK_WITH_PROTOCOLS
ERR_TLS_CERT_ALTNAME_FORMAT
ERR_TLS_CERT_ALTNAME_INVALID
ERR_TLS_DH_PARAM_SIZE
ERR_TLS_HANDSHAKE_TIMEOUT
ERR_TLS_INVALID_CONTEXT
ERR_TLS_INVALID_PROTOCOL_METHOD
ERR_TLS_INVALID_PROTOCOL_VERSION
ERR_TLS_INVALID_STATE
ERR_TLS_PROTOCOL_VERSION_CONFLICT
ERR_TLS_PSK_SET_IDENTIY_HINT_FAILED
ERR_TLS_RENEGOTIATION_DISABLED
ERR_TLS_REQUIRED_SERVER_NAME
ERR_TLS_SESSION_ATTACK
ERR_TLS_SNI_FROM_SERVER
ERR_TRACE_EVENTS_CATEGORY_REQUIRED
ERR_TRACE_EVENTS_UNAVAILABLE
ERR_TRANSFORM_ALREADY_TRANSFORMING
ERR_TRANSFORM_WITH_LENGTH_0
ERR_TTY_INIT_FAILED
ERR_UNAVAILABLE_DURING_EXIT
ERR_UNCAUGHT_EXCEPTION_CAPTURE_ALREADY_SET
ERR_UNESCAPED_CHARACTERS
ERR_UNHANDLED_ERROR
ERR_UNKNOWN_BUILTIN_MODULE
ERR_UNKNOWN_CREDENTIAL
ERR_UNKNOWN_ENCODING
ERR_UNKNOWN_FILE_EXTENSION
ERR_UNKNOWN_MODULE_FORMAT
ERR_UNKNOWN_SIGNAL
ERR_UNSUPPORTED_DIR_IMPORT
ERR_UNSUPPORTED_ESM_URL_SCHEME
ERR_USE_AFTER_CLOSE
ERR_VALID_PERFORMANCE_ENTRY_TYPE
ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING_FLAG
ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING
ERR_VM_MODULE_ALREADY_LINKED
ERR_VM_MODULE_CACHED_DATA_REJECTED
ERR_VM_MODULE_CANNOT_CREATE_CACHED_DATA
ERR_VM_MODULE_DIFFERENT_CONTEXT
ERR_VM_MODULE_LINK_FAILURE
ERR_VM_MODULE_NOT_MODULE
ERR_VM_MODULE_STATUS
ERR_WASI_ALREADY_STARTED
ERR_WASI_NOT_STARTED
ERR_WEBASSEMBLY_RESPONSE
ERR_WORKER_INIT_FAILED
ERR_WORKER_INVALID_EXEC_ARGV
ERR_WORKER_NOT_RUNNING
ERR_WORKER_OUT_OF_MEMORY
ERR_WORKER_PATH
ERR_WORKER_UNSERIALIZABLE_ERROR
ERR_WORKER_UNSUPPORTED_OPERATION
ERR_ZLIB_INITIALIZATION_FAILED
HPE_HEADER_OVERFLOW
HPE_CHUNK_EXTENSIONS_OVERFLOW
HPE_UNEXPECTED_CONTENT_LENGTH
MODULE_NOT_FOUND
- 旧版 Node.js 错误代码
ERR_CANNOT_TRANSFER_OBJECT
ERR_CRYPTO_HASH_DIGEST_NO_UTF16
ERR_HTTP2_FRAME_ERROR
ERR_HTTP2_HEADERS_OBJECT
ERR_HTTP2_HEADER_REQUIRED
ERR_HTTP2_INFO_HEADERS_AFTER_RESPOND
ERR_HTTP2_STREAM_CLOSED
ERR_HTTP_INVALID_CHAR
ERR_INDEX_OUT_OF_RANGE
ERR_INVALID_OPT_VALUE
ERR_INVALID_OPT_VALUE_ENCODING
ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST
ERR_NAPI_CONS_PROTOTYPE_OBJECT
ERR_NETWORK_IMPORT_BAD_RESPONSE
ERR_NETWORK_IMPORT_DISALLOWED
ERR_NO_LONGER_SUPPORTED
ERR_OPERATION_FAILED
ERR_OUTOFMEMORY
ERR_PARSE_HISTORY_DATA
ERR_SOCKET_CANNOT_SEND
ERR_STDERR_CLOSE
ERR_STDOUT_CLOSE
ERR_STREAM_READ_NOT_IMPLEMENTED
ERR_TLS_RENEGOTIATION_FAILED
ERR_TRANSFERRING_EXTERNALIZED_SHAREDARRAYBUFFER
ERR_UNKNOWN_STDIN_TYPE
ERR_UNKNOWN_STREAM_TYPE
ERR_V8BREAKITERATOR
ERR_VALUE_OUT_OF_RANGE
ERR_VM_MODULE_NOT_LINKED
ERR_VM_MODULE_LINKING_ERRORED
ERR_WORKER_UNSUPPORTED_EXTENSION
ERR_ZLIB_BINDING_CLOSED
ERR_CPU_USAGE
- 错误
-
导航
- 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 压缩
- 其他版本
错误#
¥Errors
在 Node.js 中运行的应用通常会遇到四类错误:
¥Applications running in Node.js will generally experience four categories of errors:
-
标准的 JavaScript 错误,例如 <EvalError>、<SyntaxError>、<RangeError>、<ReferenceError>、<TypeError> 和 <URIError>。
¥Standard JavaScript errors such as <EvalError>, <SyntaxError>, <RangeError>, <ReferenceError>, <TypeError>, and <URIError>.
-
由底层操作系统约束触发的系统错误,例如尝试打开不存在的文件或尝试通过关闭的套接字发送数据。
¥System errors triggered by underlying operating system constraints such as attempting to open a file that does not exist or attempting to send data over a closed socket.
-
由应用代码触发的用户指定的错误。
¥User-specified errors triggered by application code.
-
AssertionError
是一类特殊的错误,当 Node.js 检测到不应该发生的异常逻辑违规时会触发该错误。这些通常由node:assert
模块引发。¥
AssertionError
s are a special class of error that can be triggered when Node.js detects an exceptional logic violation that should never occur. These are raised typically by thenode:assert
module.
Node.js 引发的所有 JavaScript 和系统错误都继承自标准 JavaScript <Error> 类,或者是标准 JavaScript <Error> 类的实例,并且保证至少提供该类上可用的属性。
¥All JavaScript and system errors raised by Node.js inherit from, or are instances of, the standard JavaScript <Error> class and are guaranteed to provide at least the properties available on that class.
错误冒泡和拦截#
¥Error propagation and interception
Node.js 支持多种机制来传播和处理应用运行时发生的错误。如何报告和处理这些错误完全取决于 Error
的类型和调用的 API 的风格。
¥Node.js supports several mechanisms for propagating and handling errors that
occur while an application is running. How these errors are reported and
handled depends entirely on the type of Error
and the style of the API that is
called.
所有 JavaScript 错误都作为异常处理,使用标准 JavaScript throw
机制立即生成并抛出错误。这些是使用 JavaScript 语言提供的 try…catch
构造 来处理的。
¥All JavaScript errors are handled as exceptions that immediately generate
and throw an error using the standard JavaScript throw
mechanism. These
are handled using the try…catch
construct provided by the
JavaScript language.
// Throws with a ReferenceError because z is not defined.
try {
const m = 1;
const n = m + z;
} catch (err) {
// Handle the error here.
}
对 JavaScript throw
机制的任何使用都会引发必须处理的异常,否则 Node.js 进程将立即退出。
¥Any use of the JavaScript throw
mechanism will raise an exception that
must be handled or the Node.js process will exit immediately.
除了少数例外,同步 API(任何不返回 <Promise> 也不接受 callback
函数的阻塞方法,例如 fs.readFileSync
)将使用 throw
来报告错误。
¥With few exceptions, Synchronous APIs (any blocking method that does not
return a <Promise> nor accept a callback
function, such as
fs.readFileSync
), will use throw
to report errors.
异步 API 中发生的错误可能会以多种方式报告:
¥Errors that occur within Asynchronous APIs may be reported in multiple ways:
-
某些异步方法返回 <Promise>,你应该始终考虑到它可能会被拒绝。请参阅
--unhandled-rejections
标志,了解进程如何对未处理的 promise 拒绝做出反应。¥Some asynchronous methods returns a <Promise>, you should always take into account that it might be rejected. See
--unhandled-rejections
flag for how the process will react to an unhandled promise rejection.const fs = require('fs/promises'); (async () => { let data; try { data = await fs.readFile('a file that does not exist'); } catch (err) { console.error('There was an error reading the file!', err); return; } // Otherwise handle the data })();
-
大多数接受
callback
函数的异步方法将接受作为第一个参数传给该函数的Error
对象。如果第一个参数不是null
并且是Error
的实例,则发生了应该处理的错误。¥Most asynchronous methods that accept a
callback
function will accept anError
object passed as the first argument to that function. If that first argument is notnull
and is an instance ofError
, then an error occurred that should be handled.const fs = require('node:fs'); fs.readFile('a file that does not exist', (err, data) => { if (err) { console.error('There was an error reading the file!', err); return; } // Otherwise handle the data });
-
当在
EventEmitter
对象上调用异步方法时,错误可以路由到该对象的'error'
事件。¥When an asynchronous method is called on an object that is an
EventEmitter
, errors can be routed to that object's'error'
event.const net = require('node:net'); const connection = net.connect('localhost'); // Adding an 'error' event handler to a stream: connection.on('error', (err) => { // If the connection is reset by the server, or if it can't // connect at all, or on any sort of error encountered by // the connection, the error will be sent here. console.error(err); }); connection.pipe(process.stdout);
-
Node.js API 中的一些典型的异步方法可能仍然使用
throw
机制来引发必须使用try…catch
处理的异常。没有此类方法的完整列表;请参考每种方法的文档以确定所需的适当错误处理机制。¥A handful of typically asynchronous methods in the Node.js API may still use the
throw
mechanism to raise exceptions that must be handled usingtry…catch
. There is no comprehensive list of such methods; please refer to the documentation of each method to determine the appropriate error handling mechanism required.
'error'
事件机制的使用最常见于 stream-based 和 基于事件触发器 API,它们本身代表随时间推移的一系列异步操作(与可能通过或失败的单个操作相反)。
¥The use of the 'error'
event mechanism is most common for stream-based
and event emitter-based APIs, which themselves represent a series of
asynchronous operations over time (as opposed to a single operation that may
pass or fail).
对于所有 EventEmitter
对象,如果没有提供 'error'
事件处理程序,将抛出错误,导致 Node.js 进程报告未捕获的异常并崩溃,除非:已为 'uncaughtException'
事件注册了处理程序,或者使用了已弃用的 node:domain
模块。
¥For all EventEmitter
objects, if an 'error'
event handler is not
provided, the error will be thrown, causing the Node.js process to report an
uncaught exception and crash unless either: a handler has been registered for
the 'uncaughtException'
event, or the deprecated node:domain
module is used.
const EventEmitter = require('node:events');
const ee = new EventEmitter();
setImmediate(() => {
// This will crash the process because no 'error' event
// handler has been added.
ee.emit('error', new Error('This will crash'));
});
以这种方式产生的错误无法使用 try…catch
拦截,因为它们是在调用代码已经退出后抛出的。
¥Errors generated in this way cannot be intercepted using try…catch
as
they are thrown after the calling code has already exited.
开发者必须参考每种方法的文档,以确定这些方法引发的错误是如何传播的。
¥Developers must refer to the documentation for each method to determine exactly how errors raised by those methods are propagated.
类:Error
#
¥Class: Error
通用的 JavaScript <Error> 对象,不表示发生错误的任何具体情况。Error
对象捕获 "堆栈跟踪",详细说明代码中实例化 Error
的点,并可能提供错误的文本描述。
¥A generic JavaScript <Error> object that does not denote any specific
circumstance of why the error occurred. Error
objects capture a "stack trace"
detailing the point in the code at which the Error
was instantiated, and may
provide a text description of the error.
Node.js 生成的所有错误,包括所有系统和 JavaScript 错误,都将是 Error
类的实例或继承自 Error
类。
¥All errors generated by Node.js, including all system and JavaScript errors,
will either be instances of, or inherit from, the Error
class.
new Error(message[, options])
#
创建新的 Error
对象并将 error.message
属性设置为提供的文本消息。如果对象作为 message
传入,则通过调用 String(message)
生成文本消息。如果提供了 cause
选项,则将其分配给 error.cause
属性。error.stack
属性将代表代码中调用 new Error()
的点。堆栈跟踪依赖于 V8 的堆栈跟踪 API。堆栈跟踪仅扩展到 (a) 同步代码执行的开始,或 (b) 属性 Error.stackTraceLimit
给出的帧数,以较小者为准。
¥Creates a new Error
object and sets the error.message
property to the
provided text message. If an object is passed as message
, the text message
is generated by calling String(message)
. If the cause
option is provided,
it is assigned to the error.cause
property. The error.stack
property will
represent the point in the code at which new Error()
was called. Stack traces
are dependent on V8's stack trace API. Stack traces extend only to either
(a) the beginning of synchronous code execution, or (b) the number of frames
given by the property Error.stackTraceLimit
, whichever is smaller.
Error.captureStackTrace(targetObject[, constructorOpt])
#
-
targetObject
<Object> -
constructorOpt
<Function>
在 targetObject
上创建 .stack
属性,访问时返回表示调用 Error.captureStackTrace()
的代码中的位置的字符串。
¥Creates a .stack
property on targetObject
, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace()
was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`
跟踪的第一行将以 ${myObject.name}: ${myObject.message}
为前缀。
¥The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}
.
可选的 constructorOpt
参数接受一个函数。如果给定,则所有 constructorOpt
以上的帧,包括 constructorOpt
,都将从生成的堆栈跟踪中省略。
¥The optional constructorOpt
argument accepts a function. If given, all frames
above constructorOpt
, including constructorOpt
, will be omitted from the
generated stack trace.
constructorOpt
参数对于向用户隐藏错误生成的实现细节很有用。例如:
¥The constructorOpt
argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();
Error.stackTraceLimit
#
Error.stackTraceLimit
属性指定堆栈跟踪收集的堆栈帧数(无论是由 new Error().stack
还是 Error.captureStackTrace(obj)
生成)。
¥The Error.stackTraceLimit
property specifies the number of stack frames
collected by a stack trace (whether generated by new Error().stack
or
Error.captureStackTrace(obj)
).
默认值为 10
,但可以设置为任何有效的 JavaScript 数值。更改将影响值更改后捕获的任何堆栈跟踪。
¥The default value is 10
but may be set to any valid JavaScript number. Changes
will affect any stack trace captured after the value has been changed.
如果设置为非数字值,或设置为负数,则堆栈跟踪将不会捕获任何帧。
¥If set to a non-number value, or set to a negative number, stack traces will not capture any frames.
error.cause
#
如果存在,则 error.cause
属性是 Error
的根本原因。当捕获一个错误并抛出一个带有不同消息或代码的新错误以便仍然可以访问原始错误时使用它。
¥If present, the error.cause
property is the underlying cause of the Error
.
It is used when catching an error and throwing a new one with a different
message or code in order to still have access to the original error.
error.cause
属性通常通过调用 new Error(message, { cause })
来设置。如果没有提供 cause
选项,则不是构造函数设置的。
¥The error.cause
property is typically set by calling
new Error(message, { cause })
. It is not set by the constructor if the
cause
option is not provided.
此属性允许链接错误。当序列化 Error
对象时,如果设置了 util.inspect()
,则递归序列化 error.cause
。
¥This property allows errors to be chained. When serializing Error
objects,
util.inspect()
recursively serializes error.cause
if it is set.
const cause = new Error('The remote HTTP server responded with a 500 status');
const symptom = new Error('The message failed to send', { cause });
console.log(symptom);
// Prints:
// Error: The message failed to send
// at REPL2:1:17
// at Script.runInThisContext (node:vm:130:12)
// ... 7 lines matching cause stack trace ...
// at [_line] [as _line] (node:internal/readline/interface:886:18) {
// [cause]: Error: The remote HTTP server responded with a 500 status
// at REPL1:1:15
// at Script.runInThisContext (node:vm:130:12)
// at REPLServer.defaultEval (node:repl:574:29)
// at bound (node:domain:426:15)
// at REPLServer.runBound [as eval] (node:domain:437:12)
// at REPLServer.onLine (node:repl:902:10)
// at REPLServer.emit (node:events:549:35)
// at REPLServer.emit (node:domain:482:12)
// at [_onLine] [as _onLine] (node:internal/readline/interface:425:12)
// at [_line] [as _line] (node:internal/readline/interface:886:18)
error.code
#
error.code
属性是标识错误类型的字符串标签。error.code
是识别错误的最稳定方式。它只会在 Node.js 的主要版本之间发生变化。相比之下,error.message
字符串可能会在任何版本的 Node.js 之间发生变化。有关具体代码的详细信息,请参见 Node.js 错误代码。
¥The error.code
property is a string label that identifies the kind of error.
error.code
is the most stable way to identify an error. It will only change
between major versions of Node.js. In contrast, error.message
strings may
change between any versions of Node.js. See Node.js error codes for details
about specific codes.
error.message
#
error.message
属性是通过调用 new Error(message)
设置的错误的字符串描述。传递给构造函数的 message
也会出现在 Error
的堆栈跟踪的第一行,但是在创建 Error
对象后更改此属性可能不会更改堆栈跟踪的第一行(例如,当之前读取 error.stack
时 此属性已更改)。
¥The error.message
property is the string description of the error as set by
calling new Error(message)
. The message
passed to the constructor will also
appear in the first line of the stack trace of the Error
, however changing
this property after the Error
object is created may not change the first
line of the stack trace (for example, when error.stack
is read before this
property is changed).
const err = new Error('The message');
console.error(err.message);
// Prints: The message
error.stack
#
error.stack
属性是描述代码中实例化 Error
的点的字符串。
¥The error.stack
property is a string describing the point in the code at which
the Error
was instantiated.
Error: Things keep happening!
at /home/gbusey/file.js:525:2
at Frobnicator.refrobulate (/home/gbusey/business-logic.js:424:21)
at Actor.<anonymous> (/home/gbusey/actors.js:400:8)
at increaseSynergy (/home/gbusey/actors.js:701:6)
第一行的格式为 <error class name>: <error message>
,后面是一系列堆栈帧(每行以 "at" 开头)。每一帧都描述了代码中导致错误生成的调用点。V8 尝试为每个函数显示名称(通过变量名、函数名、或对象方法名),但偶尔会找不到合适的名称。如果 V8 无法确定函数的名称,则只会显示该帧的位置信息。否则,将显示确定的函数名称,括号中会附加位置信息。
¥The first line is formatted as <error class name>: <error message>
, and
is followed by a series of stack frames (each line beginning with "at ").
Each frame describes a call site within the code that lead to the error being
generated. V8 attempts to display a name for each function (by variable name,
function name, or object method name), but occasionally it will not be able to
find a suitable name. If V8 cannot determine a name for the function, only
location information will be displayed for that frame. Otherwise, the
determined function name will be displayed with location information appended
in parentheses.
帧仅为 JavaScript 函数生成。例如,如果执行同步通过名为 cheetahify
的 C++ 插件函数,该函数本身调用 JavaScript 函数,则表示 cheetahify
调用的帧将不会出现在堆栈跟踪中:
¥Frames are only generated for JavaScript functions. If, for example, execution
synchronously passes through a C++ addon function called cheetahify
which
itself calls a JavaScript function, the frame representing the cheetahify
call
will not be present in the stack traces:
const cheetahify = require('./native-binding.node');
function makeFaster() {
// `cheetahify()` *synchronously* calls speedy.
cheetahify(function speedy() {
throw new Error('oh no!');
});
}
makeFaster();
// will throw:
// /home/gbusey/file.js:6
// throw new Error('oh no!');
// ^
// Error: oh no!
// at speedy (/home/gbusey/file.js:6:11)
// at makeFaster (/home/gbusey/file.js:5:3)
// at Object.<anonymous> (/home/gbusey/file.js:10:1)
// at Module._compile (module.js:456:26)
// at Object.Module._extensions..js (module.js:474:10)
// at Module.load (module.js:356:32)
// at Function.Module._load (module.js:312:12)
// at Function.Module.runMain (module.js:497:10)
// at startup (node.js:119:16)
// at node.js:906:3
位置信息将是以下之一:
¥The location information will be one of:
-
native
, 如果帧代表 V8 内部的调用(如[].forEach
)。¥
native
, if the frame represents a call internal to V8 (as in[].forEach
). -
plain-filename.js:line:column
, 如果帧代表 Node.js 内部调用¥
plain-filename.js:line:column
, if the frame represents a call internal to Node.js. -
如果帧代表用户程序中的调用(使用 CommonJS 模块系统)或其依赖,则为
/absolute/path/to/file.js:line:column
。¥
/absolute/path/to/file.js:line:column
, if the frame represents a call in a user program (using CommonJS module system), or its dependencies. -
如果帧代表用户程序中的调用(使用 ES 模块系统)或其依赖,则为
<transport-protocol>:///url/to/module/file.mjs:line:column
。¥
<transport-protocol>:///url/to/module/file.mjs:line:column
, if the frame represents a call in a user program (using ES module system), or its dependencies.
当访问 error.stack
属性时,会延迟生成表示堆栈跟踪的字符串。
¥The string representing the stack trace is lazily generated when the
error.stack
property is accessed.
堆栈跟踪捕获的帧数以 Error.stackTraceLimit
或当前事件循环刻度上的可用帧数中的较小者为界。
¥The number of frames captured by the stack trace is bounded by the smaller of
Error.stackTraceLimit
or the number of available frames on the current event
loop tick.
类:AssertionError
#
¥Class: AssertionError
-
¥Extends: <errors.Error>
表示断言的失败。详情见 Class: assert.AssertionError
。
¥Indicates the failure of an assertion. For details, see
Class: assert.AssertionError
.
类:RangeError
#
¥Class: RangeError
-
¥Extends: <errors.Error>
表示提供的参数不在函数可接受值的集合或范围内;这是一个数字范围,还是超出给定函数参数的选项集。
¥Indicates that a provided argument was not within the set or range of acceptable values for a function; whether that is a numeric range, or outside the set of options for a given function parameter.
require('node:net').connect(-1);
// Throws "RangeError: "port" option should be >= 0 and < 65536: -1"
Node.js 将立即生成并抛出 RangeError
实例作为参数验证的一种形式。
¥Node.js will generate and throw RangeError
instances immediately as a form
of argument validation.
类:ReferenceError
#
¥Class: ReferenceError
-
¥Extends: <errors.Error>
表示正在尝试访问未定义的变量。此类错误通常表示代码中存在拼写错误或程序损坏。
¥Indicates that an attempt is being made to access a variable that is not defined. Such errors commonly indicate typos in code, or an otherwise broken program.
虽然客户端代码可能会产生和传播这些错误,但实际上只有 V8 会这样做。
¥While client code may generate and propagate these errors, in practice, only V8 will do so.
doesNotExist;
// Throws ReferenceError, doesNotExist is not a variable in this program.
除非应用动态生成和运行代码,否则 ReferenceError
实例表明代码或其依赖中存在错误。
¥Unless an application is dynamically generating and running code,
ReferenceError
instances indicate a bug in the code or its dependencies.
类:SyntaxError
#
¥Class: SyntaxError
-
¥Extends: <errors.Error>
表示程序不是有效的 JavaScript。这些错误只能作为代码评估的结果生成和传播。代码评估可能作为 eval
、Function
、require
或 vm 的结果发生。这些错误几乎始终表明程序损坏。
¥Indicates that a program is not valid JavaScript. These errors may only be
generated and propagated as a result of code evaluation. Code evaluation may
happen as a result of eval
, Function
, require
, or vm. These errors
are almost always indicative of a broken program.
try {
require('node:vm').runInThisContext('binary ! isNotOk');
} catch (err) {
// 'err' will be a SyntaxError.
}
SyntaxError
实例在创建它们的上下文中是不可恢复的 - 它们只能被其他上下文捕获。
¥SyntaxError
instances are unrecoverable in the context that created them –
they may only be caught by other contexts.
类:SystemError
#
¥Class: SystemError
-
¥Extends: <errors.Error>
Node.js 在其运行时环境中发生异常时会生成系统错误。这些通常发生在应用违反操作系统约束时。例如,如果应用尝试读取不存在的文件,则会发生系统错误。
¥Node.js generates system errors when exceptions occur within its runtime environment. These usually occur when an application violates an operating system constraint. For example, a system error will occur if an application attempts to read a file that does not exist.
-
address
<string> 如果存在,则为网络连接失败的地址¥
address
<string> If present, the address to which a network connection failed -
code
<string> 字符串错误码¥
code
<string> The string error code -
dest
<string> 如果存在,则为报告文件系统错误时的文件路径目标¥
dest
<string> If present, the file path destination when reporting a file system error -
errno
<number> 系统提供的错误号¥
errno
<number> The system-provided error number -
info
<Object> 如果存在,则为关于错误情况的额外细节¥
info
<Object> If present, extra details about the error condition -
message
<string> 系统提供的人类可读的错误描述¥
message
<string> A system-provided human-readable description of the error -
path
<string> 如果存在,则为报告文件系统错误时的文件路径¥
path
<string> If present, the file path when reporting a file system error -
port
<number> 如果存在,则为不可用的网络连接端口¥
port
<number> If present, the network connection port that is not available -
syscall
<string> 触发错误的系统调用名称¥
syscall
<string> The name of the system call that triggered the error
error.address
#
如果存在,则 error.address
是描述网络连接失败的地址的字符串。
¥If present, error.address
is a string describing the address to which a
network connection failed.
error.code
#
error.code
属性是表示错误代码的字符串。
¥The error.code
property is a string representing the error code.
error.dest
#
如果存在,则 error.dest
是报告文件系统错误时的文件路径目标。
¥If present, error.dest
is the file path destination when reporting a file
system error.
error.errno
#
error.errno
属性是对应于 libuv Error handling
中定义的错误码的负数。
¥The error.errno
property is a negative number which corresponds
to the error code defined in libuv Error handling
.
在 Windows 上,系统提供的错误号将由 libuv 规范化。
¥On Windows the error number provided by the system will be normalized by libuv.
要获取错误码的字符串表示,则使用 util.getSystemErrorName(error.errno)
。
¥To get the string representation of the error code, use
util.getSystemErrorName(error.errno)
.
error.info
#
如果存在,则 error.info
是包含错误情况详细信息的对象。
¥If present, error.info
is an object with details about the error condition.
error.message
#
error.message
是系统提供的人类可读的错误描述。
¥error.message
is a system-provided human-readable description of the error.
error.path
#
如果存在,则 error.path
是包含相关无效路径名的字符串。
¥If present, error.path
is a string containing a relevant invalid pathname.
error.port
#
如果存在,则 error.port
是不可用的网络连接端口。
¥If present, error.port
is the network connection port that is not available.
error.syscall
#
error.syscall
属性是描述失败的 系统调用 的字符串。
¥The error.syscall
property is a string describing the syscall that failed.
常见系统错误#
¥Common system errors
这是编写 Node.js 程序时经常遇到的系统错误列表。有关完整列表,请参阅 errno
(3) 手册页。
¥This is a list of system errors commonly-encountered when writing a Node.js
program. For a comprehensive list, see the errno
(3) man page.
-
EACCES
(权限被拒绝):试图以文件访问权限禁止的方式访问文件。¥
EACCES
(Permission denied): An attempt was made to access a file in a way forbidden by its file access permissions. -
EADDRINUSE
(地址已被使用):由于本地系统上的另一台服务器已占用该地址,尝试将服务器(net
、http
或https
)绑定到本地地址失败。¥
EADDRINUSE
(Address already in use): An attempt to bind a server (net
,http
, orhttps
) to a local address failed due to another server on the local system already occupying that address. -
ECONNREFUSED
(连接被拒绝):由于目标机器主动拒绝,无法建立连接。这通常是由于尝试连接到在外部主机上处于非活动状态的服务。¥
ECONNREFUSED
(Connection refused): No connection could be made because the target machine actively refused it. This usually results from trying to connect to a service that is inactive on the foreign host. -
ECONNRESET
(对等方重置连接):连接被对等方强行关闭。这通常是由于超时或重新启动导致远程套接字上的连接丢失造成的。通常通过http
和net
模块遇到。¥
ECONNRESET
(Connection reset by peer): A connection was forcibly closed by a peer. This normally results from a loss of the connection on the remote socket due to a timeout or reboot. Commonly encountered via thehttp
andnet
modules. -
EEXIST
(文件存在):现有文件是要求目标不存在的操作的目标。¥
EEXIST
(File exists): An existing file was the target of an operation that required that the target not exist. -
EISDIR
(是一个目录):一个操作需要一个文件,但给定的路径名是一个目录。¥
EISDIR
(Is a directory): An operation expected a file, but the given pathname was a directory. -
EMFILE
(系统中打开的文件太多):已达到系统允许的最大 文件描述符 数量,并且在至少关闭一个描述符之前无法满足对另一个描述符的请求。同时打开多个文件时会遇到这种情况,尤其是在进程的文件描述符限制较低的系统(特别是 macOS)上。要弥补低限制,则在将运行 Node.js 进程的同一个 shell 中运行ulimit -n 2048
。¥
EMFILE
(Too many open files in system): Maximum number of file descriptors allowable on the system has been reached, and requests for another descriptor cannot be fulfilled until at least one has been closed. This is encountered when opening many files at once in parallel, especially on systems (in particular, macOS) where there is a low file descriptor limit for processes. To remedy a low limit, runulimit -n 2048
in the same shell that will run the Node.js process. -
ENOENT
(没有这样的文件或目录):通常由fs
操作引发以指示指定路径名的组件不存在。给定路径找不到任何实体(文件或目录)。¥
ENOENT
(No such file or directory): Commonly raised byfs
operations to indicate that a component of the specified pathname does not exist. No entity (file or directory) could be found by the given path. -
ENOTDIR
(不是目录):给定路径名的组件存在,但不是预期的目录。通常由fs.readdir
引起。¥
ENOTDIR
(Not a directory): A component of the given pathname existed, but was not a directory as expected. Commonly raised byfs.readdir
. -
ENOTEMPTY
(目录非空):包含条目的目录是需要空目录(通常为fs.unlink
)的操作的目标。¥
ENOTEMPTY
(Directory not empty): A directory with entries was the target of an operation that requires an empty directory, usuallyfs.unlink
. -
ENOTFOUND
(DNS 查找失败):指示EAI_NODATA
或EAI_NONAME
的 DNS 故障。这不是标准的 POSIX 错误。¥
ENOTFOUND
(DNS lookup failed): Indicates a DNS failure of eitherEAI_NODATA
orEAI_NONAME
. This is not a standard POSIX error. -
EPERM
(不允许操作):试图执行需要提升权限的操作。¥
EPERM
(Operation not permitted): An attempt was made to perform an operation that requires elevated privileges. -
EPIPE
(破管):在没有进程读取数据的管道、套接字或 FIFO 上写入。通常发生在net
和http
层,表示正在写入的流的远程端已关闭。¥
EPIPE
(Broken pipe): A write on a pipe, socket, or FIFO for which there is no process to read the data. Commonly encountered at thenet
andhttp
layers, indicative that the remote side of the stream being written to has been closed. -
ETIMEDOUT
(操作超时):连接或发送请求失败,因为连接方在一段时间后没有正确响应。通常发生在http
或net
。通常表明socket.end()
没有被正确地调用。¥
ETIMEDOUT
(Operation timed out): A connect or send request failed because the connected party did not properly respond after a period of time. Usually encountered byhttp
ornet
. Often a sign that asocket.end()
was not properly called.
类:TypeError
#
¥Class: TypeError
-
¥Extends <errors.Error>
表示提供的参数不是允许的类型。例如,将函数传给期望字符串为 TypeError
的参数。
¥Indicates that a provided argument is not an allowable type. For example,
passing a function to a parameter which expects a string would be a TypeError
.
require('node:url').parse(() => { });
// Throws TypeError, since it expected a string.
Node.js 将立即生成并抛出 TypeError
实例作为参数验证的一种形式。
¥Node.js will generate and throw TypeError
instances immediately as a form
of argument validation.
异常与错误#
¥Exceptions vs. errors
JavaScript 异常是由于无效操作或作为 throw
语句的目标而抛出的值。虽然不要求这些值是 Error
的实例或从 Error
继承的类,但 Node.js 或 JavaScript 运行时抛出的所有异常都将是 Error
的实例。
¥A JavaScript exception is a value that is thrown as a result of an invalid
operation or as the target of a throw
statement. While it is not required
that these values are instances of Error
or classes which inherit from
Error
, all exceptions thrown by Node.js or the JavaScript runtime will be
instances of Error
.
有些异常在 JavaScript 层是不可恢复的。这种异常总是会导致 Node.js 进程崩溃。示例包括 C++ 层中的 assert()
检查或 abort()
调用。
¥Some exceptions are unrecoverable at the JavaScript layer. Such exceptions
will always cause the Node.js process to crash. Examples include assert()
checks or abort()
calls in the C++ layer.
OpenSSL 错误#
¥OpenSSL errors
源自 crypto
或 tls
的错误属于 Error
类,除了标准的 .code
和 .message
属性外,可能还有一些额外的 OpenSSL 特定属性。
¥Errors originating in crypto
or tls
are of class Error
, and in addition to
the standard .code
and .message
properties, may have some additional
OpenSSL-specific properties.
error.opensslErrorStack
#
可以为 OpenSSL 库中错误源自的位置提供上下文的错误数组。
¥An array of errors that can give context to where in the OpenSSL library an error originates from.
error.function
#
错误源自的 OpenSSL 函数。
¥The OpenSSL function the error originates in.
error.library
#
错误源自的 OpenSSL 库。
¥The OpenSSL library the error originates in.
error.reason
#
描述错误原因的人类可读的字符串。
¥A human-readable string describing the reason for the error.
Node.js 错误代码#
¥Node.js error codes
ABORT_ERR
#
当操作中止时使用(通常使用 AbortController
)。
¥Used when an operation has been aborted (typically using an AbortController
).
不使用 AbortSignal
的 API 通常不会引发此代码的错误。
¥APIs not using AbortSignal
s typically do not raise an error with this code.
此代码未使用 Node.js 错误使用的常规 ERR_*
约定,以便与网络平台的 AbortError
兼容。
¥This code does not use the regular ERR_*
convention Node.js errors use in
order to be compatible with the web platform's AbortError
.
ERR_ACCESS_DENIED
#
每当 Node.js 尝试访问受 policy 清单限制的资源时,就会触发一种特殊类型的错误。例如,process.binding
。
¥A special type of error that is triggered whenever Node.js tries to get access
to a resource restricted by the policy manifest.
For example, process.binding
.
ERR_AMBIGUOUS_ARGUMENT
#
函数参数的使用方式表明函数签名可能会被误解。当 assert.throws(block, message)
中的 message
参数与 block
抛出的错误消息匹配时,则由 node:assert
模块抛出错误,因为这种用法表明用户认为 message
是预期的消息,而不是 block
不抛出时 AssertionError
将显示的消息。
¥A function argument is being used in a way that suggests that the function
signature may be misunderstood. This is thrown by the node:assert
module when
the message
parameter in assert.throws(block, message)
matches the error
message thrown by block
because that usage suggests that the user believes
message
is the expected message rather than the message the AssertionError
will display if block
does not throw.
ERR_ARG_NOT_ITERABLE
#
需要可迭代的参数(即适用于 for...of
循环的值),但未提供给 Node.js API。
¥An iterable argument (i.e. a value that works with for...of
loops) was
required, but not provided to a Node.js API.
ERR_ASSERTION
#
特殊类型的错误,每当 Node.js 检测到不应该发生的异常逻辑违规时就会触发。这些通常由 node:assert
模块引发。
¥A special type of error that can be triggered whenever Node.js detects an
exceptional logic violation that should never occur. These are raised typically
by the node:assert
module.
ERR_ASYNC_CALLBACK
#
试图将不是函数的东西注册为 AsyncHooks
回调。
¥An attempt was made to register something that is not a function as an
AsyncHooks
callback.
ERR_ASYNC_TYPE
#
异步资源的类型无效。如果使用公共的嵌入器 API,则用户还可以定义自己的类型。
¥The type of an asynchronous resource was invalid. Users are also able to define their own types if using the public embedder API.
ERR_BROTLI_COMPRESSION_FAILED
#
传给 Brotli 流的数据未成功压缩。
¥Data passed to a Brotli stream was not successfully compressed.
ERR_BROTLI_INVALID_PARAM
#
在构建 Brotli 流期间传入了无效的参数键。
¥An invalid parameter key was passed during construction of a Brotli stream.
ERR_BUFFER_CONTEXT_NOT_AVAILABLE
#
尝试从插件或嵌入器代码创建 Node.js Buffer
实例,而在与 Node.js 实例无关的 JS 引擎上下文中。传给 Buffer
方法的数据将在方法返回时被释放。
¥An attempt was made to create a Node.js Buffer
instance from addon or embedder
code, while in a JS engine Context that is not associated with a Node.js
instance. The data passed to the Buffer
method will have been released
by the time the method returns.
当遇到此错误时,创建 Buffer
实例的一种可能的替代方法是创建普通的 Uint8Array
,它仅在生成的对象的原型上有所不同。Uint8Array
在所有 Node.js 核心 API 中普遍接受,而 Buffer
是;它们在所有上下文中都可用。
¥When encountering this error, a possible alternative to creating a Buffer
instance is to create a normal Uint8Array
, which only differs in the
prototype of the resulting object. Uint8Array
s are generally accepted in all
Node.js core APIs where Buffer
s are; they are available in all Contexts.
ERR_BUFFER_OUT_OF_BOUNDS
#
尝试了超出 Buffer
范围的操作。
¥An operation outside the bounds of a Buffer
was attempted.
ERR_BUFFER_TOO_LARGE
#
已尝试创建大于最大允许大小的 Buffer
。
¥An attempt has been made to create a Buffer
larger than the maximum allowed
size.
ERR_CANNOT_WATCH_SIGINT
#
Node.js 无法监视 SIGINT
信号。
¥Node.js was unable to watch for the SIGINT
signal.
ERR_CHILD_CLOSED_BEFORE_REPLY
#
在父进程收到响应之前子进程已关闭。
¥A child process was closed before the parent received a reply.
ERR_CHILD_PROCESS_IPC_REQUIRED
#
当在没有指定进程间通信通道的情况下衍生子进程时使用。
¥Used when a child process is being forked without specifying an IPC channel.
ERR_CHILD_PROCESS_STDIO_MAXBUFFER
#
当主进程试图从子进程的标准错误或标准输出读取数据、并且数据的长度比 maxBuffer
选项长时使用。
¥Used when the main process is trying to read data from the child process's
STDERR/STDOUT, and the data's length is longer than the maxBuffer
option.
ERR_CLOSED_MESSAGE_PORT
#
曾试图在关闭状态下使用 MessagePort
实例,通常是在调用 .close()
之后。
¥There was an attempt to use a MessagePort
instance in a closed
state, usually after .close()
has been called.
ERR_CONSOLE_WRITABLE_STREAM
#
Console
在没有 stdout
流的情况下被实例化,或者 Console
有不可写的 stdout
或 stderr
流。
¥Console
was instantiated without stdout
stream, or Console
has a
non-writable stdout
or stderr
stream.
ERR_CONSTRUCT_CALL_INVALID
#
调用了不可调用的类构造函数。
¥A class constructor was called that is not callable.
ERR_CONSTRUCT_CALL_REQUIRED
#
在没有 new
的情况下调用了类的构造函数。
¥A constructor for a class was called without new
.
ERR_CONTEXT_NOT_INITIALIZED
#
传入 API 的虚拟机上下文尚未初始化。这可能发生在上下文创建过程中发生(并被捕获)错误时,例如,当分配失败或在创建上下文时达到最大调用堆栈大小时。
¥The vm context passed into the API is not yet initialized. This could happen when an error occurs (and is caught) during the creation of the context, for example, when the allocation fails or the maximum call stack size is reached when the context is created.
ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED
#
所请求的 OpenSSL 引擎(例如,通过 clientCertEngine
或 privateKeyEngine
TLS 选项)不受正在使用的 OpenSSL 版本的支持,可能是由于编译时标志 OPENSSL_NO_ENGINE
。
¥An OpenSSL engine was requested (for example, through the clientCertEngine
or
privateKeyEngine
TLS options) that is not supported by the version of OpenSSL
being used, likely due to the compile-time flag OPENSSL_NO_ENGINE
.
ERR_CRYPTO_ECDH_INVALID_FORMAT
#
format
参数的无效值被传给 crypto.ECDH()
类 getPublicKey()
方法。
¥An invalid value for the format
argument was passed to the crypto.ECDH()
class getPublicKey()
method.
ERR_CRYPTO_ECDH_INVALID_PUBLIC_KEY
#
key
参数的无效值已传给 crypto.ECDH()
类 computeSecret()
方法。这意味着公钥位于椭圆曲线之外。
¥An invalid value for the key
argument has been passed to the
crypto.ECDH()
class computeSecret()
method. It means that the public
key lies outside of the elliptic curve.
ERR_CRYPTO_ENGINE_UNKNOWN
#
无效的加密引擎标识符被传给 require('node:crypto').setEngine()
。
¥An invalid crypto engine identifier was passed to
require('node:crypto').setEngine()
.
ERR_CRYPTO_FIPS_FORCED
#
使用了 --force-fips
命令行参数,但尝试在 node:crypto
模块中启用或禁用 FIPS 模式。
¥The --force-fips
command-line argument was used but there was an attempt
to enable or disable FIPS mode in the node:crypto
module.
ERR_CRYPTO_FIPS_UNAVAILABLE
#
尝试启用或禁用 FIPS 模式,但 FIPS 模式不可用。
¥An attempt was made to enable or disable FIPS mode, but FIPS mode was not available.
ERR_CRYPTO_HASH_FINALIZED
#
hash.digest()
被多次调用。对于 Hash
对象的每个实例,调用 hash.digest()
方法的次数不得超过一次。
¥hash.digest()
was called multiple times. The hash.digest()
method must
be called no more than one time per instance of a Hash
object.
ERR_CRYPTO_HASH_UPDATE_FAILED
#
hash.update()
因任何原因失败。这应该很少发生,如果有的话。
¥hash.update()
failed for any reason. This should rarely, if ever, happen.
ERR_CRYPTO_INCOMPATIBLE_KEY
#
给定的加密密钥与尝试的操作不兼容。
¥The given crypto keys are incompatible with the attempted operation.
ERR_CRYPTO_INCOMPATIBLE_KEY_OPTIONS
#
所选的公钥或私钥编码与其他选项不兼容。
¥The selected public or private key encoding is incompatible with other options.
ERR_CRYPTO_INITIALIZATION_FAILED
#
加密子系统初始化失败。
¥Initialization of the crypto subsystem failed.
ERR_CRYPTO_INVALID_AUTH_TAG
#
提供了无效的身份验证标签。
¥An invalid authentication tag was provided.
ERR_CRYPTO_INVALID_COUNTER
#
为计数器模式密码提供了无效的计数器。
¥An invalid counter was provided for a counter-mode cipher.
ERR_CRYPTO_INVALID_CURVE
#
提供了无效的椭圆曲线。
¥An invalid elliptic-curve was provided.
ERR_CRYPTO_INVALID_DIGEST
#
指定了无效的 加密摘要算法。
¥An invalid crypto digest algorithm was specified.
ERR_CRYPTO_INVALID_IV
#
提供了无效的初始化向量。
¥An invalid initialization vector was provided.
ERR_CRYPTO_INVALID_JWK
#
提供了无效的 JSON 网络密钥。
¥An invalid JSON Web Key was provided.
ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE
#
给定的加密密钥对象的类型对于尝试的操作无效。
¥The given crypto key object's type is invalid for the attempted operation.
ERR_CRYPTO_INVALID_KEYLEN
#
提供了无效的密钥长度。
¥An invalid key length was provided.
ERR_CRYPTO_INVALID_KEYPAIR
#
提供了无效的密钥对。
¥An invalid key pair was provided.
ERR_CRYPTO_INVALID_KEYTYPE
#
提供了无效的密钥类型。
¥An invalid key type was provided.
ERR_CRYPTO_INVALID_MESSAGELEN
#
提供了无效的消息长度。
¥An invalid message length was provided.
ERR_CRYPTO_INVALID_SCRYPT_PARAMS
#
提供了无效的 scrypt 算法参数。
¥Invalid scrypt algorithm parameters were provided.
ERR_CRYPTO_INVALID_STATE
#
对处于无效状态的对象使用了加密方法。例如,在调用 cipher.final()
之前调用 cipher.getAuthTag()
。
¥A crypto method was used on an object that was in an invalid state. For
instance, calling cipher.getAuthTag()
before calling cipher.final()
.
ERR_CRYPTO_INVALID_TAG_LENGTH
#
提供了无效的身份验证标签长度。
¥An invalid authentication tag length was provided.
ERR_CRYPTO_JOB_INIT_FAILED
#
异步加密操作的初始化失败。
¥Initialization of an asynchronous crypto operation failed.
ERR_CRYPTO_JWK_UNSUPPORTED_CURVE
#
Key 的椭圆曲线未注册用于 JSON Web 密钥椭圆曲线注册表。
¥Key's Elliptic Curve is not registered for use in the JSON Web Key Elliptic Curve Registry.
ERR_CRYPTO_JWK_UNSUPPORTED_KEY_TYPE
#
密钥的非对称密钥类型未注册用于 JSON Web 密钥类型注册表。
¥Key's Asymmetric Key Type is not registered for use in the JSON Web Key Types Registry.
ERR_CRYPTO_OPERATION_FAILED
#
加密操作失败,原因不明。
¥A crypto operation failed for an otherwise unspecified reason.
ERR_CRYPTO_PBKDF2_ERROR
#
PBKDF2 算法因不明原因失败。OpenSSL 没有提供更多细节,因此 Node.js 也没有。
¥The PBKDF2 algorithm failed for unspecified reasons. OpenSSL does not provide more details and therefore neither does Node.js.
ERR_CRYPTO_SCRYPT_INVALID_PARAMETER
#
一个或多个 crypto.scrypt()
或 crypto.scryptSync()
参数超出其合法范围。
¥One or more crypto.scrypt()
or crypto.scryptSync()
parameters are
outside their legal range.
ERR_CRYPTO_SCRYPT_NOT_SUPPORTED
#
Node.js 是在没有 scrypt
支持的情况下编译的。官方发布的二进制文件不可能,但自定义构建可能会发生,包括发行版构建。
¥Node.js was compiled without scrypt
support. Not possible with the official
release binaries but can happen with custom builds, including distro builds.
ERR_CRYPTO_SIGN_KEY_REQUIRED
#
未向 sign.sign()
方法提供签名 key
。
¥A signing key
was not provided to the sign.sign()
method.
ERR_CRYPTO_TIMING_SAFE_EQUAL_LENGTH
#
crypto.timingSafeEqual()
是用不同长度的 Buffer
、TypedArray
或 DataView
参数调用的。
¥crypto.timingSafeEqual()
was called with Buffer
, TypedArray
, or
DataView
arguments of different lengths.
ERR_CRYPTO_UNKNOWN_CIPHER
#
指定了未知的密码。
¥An unknown cipher was specified.
ERR_CRYPTO_UNKNOWN_DH_GROUP
#
给定了未知的 Diffie-Hellman 组名。有关有效组名的列表,请参阅 crypto.getDiffieHellman()
。
¥An unknown Diffie-Hellman group name was given. See
crypto.getDiffieHellman()
for a list of valid group names.
ERR_CRYPTO_UNSUPPORTED_OPERATION
#
尝试调用不受支持的加密操作。
¥An attempt to invoke an unsupported crypto operation was made.
ERR_DEBUGGER_ERROR
#
debugger 发生错误。
¥An error occurred with the debugger.
ERR_DEBUGGER_STARTUP_ERROR
#
debugger 在等待所需的主机/端口空闲时超时。
¥The debugger timed out waiting for the required host/port to be free.
ERR_DLOPEN_DISABLED
#
加载已使用 --no-addons
禁用的原生插件。
¥Loading native addons has been disabled using --no-addons
.
ERR_DLOPEN_FAILED
#
调用 process.dlopen()
失败。
¥A call to process.dlopen()
failed.
ERR_DIR_CLOSED
#
fs.Dir
先前已关闭。
¥The fs.Dir
was previously closed.
ERR_DIR_CONCURRENT_OPERATION
#
尝试在具有正在进行的异步操作的 fs.Dir
上进行同步的读取或关闭的调用。
¥A synchronous read or close call was attempted on an fs.Dir
which has
ongoing asynchronous operations.
ERR_DNS_SET_SERVERS_FAILED
#
c-ares
设置域名系统服务器失败。
¥c-ares
failed to set the DNS server.
ERR_DOMAIN_CALLBACK_NOT_AVAILABLE
#
node:domain
模块不可用,因为它无法建立所需的错误处理钩子,因为 process.setUncaughtExceptionCaptureCallback()
已在较早的时间点被调用。
¥The node:domain
module was not usable since it could not establish the
required error handling hooks, because
process.setUncaughtExceptionCaptureCallback()
had been called at an
earlier point in time.
ERR_DOMAIN_CANNOT_SET_UNCAUGHT_EXCEPTION_CAPTURE
#
无法调用 process.setUncaughtExceptionCaptureCallback()
,因为 node:domain
模块已在较早的时间点加载。
¥process.setUncaughtExceptionCaptureCallback()
could not be called
because the node:domain
module has been loaded at an earlier point in time.
堆栈跟踪扩展到包括加载 node:domain
模块的时间点。
¥The stack trace is extended to include the point in time at which the
node:domain
module had been loaded.
ERR_DUPLICATE_STARTUP_SNAPSHOT_MAIN_FUNCTION
#
v8.startupSnapshot.setDeserializeMainFunction()
不能被调用,因为它之前已经被调用过。
¥v8.startupSnapshot.setDeserializeMainFunction()
could not be called
because it had already been called before.
ERR_ENCODING_INVALID_ENCODED_DATA
#
根据提供的编码,提供给 TextDecoder()
API 的数据无效。
¥Data provided to TextDecoder()
API was invalid according to the encoding
provided.
ERR_ENCODING_NOT_SUPPORTED
#
提供给 TextDecoder()
API 的编码不是 WHATWG 支持的编码 之一。
¥Encoding provided to TextDecoder()
API was not one of the
WHATWG Supported Encodings.
ERR_EVAL_ESM_CANNOT_PRINT
#
--print
不能与 ESM 输入一起使用。
¥--print
cannot be used with ESM input.
ERR_EVENT_RECURSION
#
当试图在 EventTarget
上递归调度事件时抛出。
¥Thrown when an attempt is made to recursively dispatch an event on EventTarget
.
ERR_EXECUTION_ENVIRONMENT_NOT_AVAILABLE
#
JS 执行上下文与 Node.js 环境无关。当 Node.js 用作嵌入式库并且 JS 引擎的一些钩子没有正确地设置时,可能会发生这种情况。
¥The JS execution context is not associated with a Node.js environment. This may occur when Node.js is used as an embedded library and some hooks for the JS engine are not set up properly.
ERR_FALSY_VALUE_REJECTION
#
通过 util.callbackify()
回调的 Promise
使用非真值拒绝。
¥A Promise
that was callbackified via util.callbackify()
was rejected with a
falsy value.
ERR_FEATURE_UNAVAILABLE_ON_PLATFORM
#
当使用了运行 Node.js 的当前平台不可用的特性时使用。
¥Used when a feature that is not available to the current platform which is running Node.js is used.
ERR_FS_CP_DIR_TO_NON_DIR
#
尝试使用 fs.cp()
将目录复制到非目录(文件、符号链接等)。
¥An attempt was made to copy a directory to a non-directory (file, symlink,
etc.) using fs.cp()
.
ERR_FS_CP_EEXIST
#
试图使用 fs.cp()
(force
和 errorOnExist
设置为 true
)复制已经存在的文件。
¥An attempt was made to copy over a file that already existed with
fs.cp()
, with the force
and errorOnExist
set to true
.
ERR_FS_CP_EINVAL
#
当使用 fs.cp()
、src
或 dest
指向无效路径时。
¥When using fs.cp()
, src
or dest
pointed to an invalid path.
ERR_HTTP_BODY_NOT_ALLOWED
#
¥An error is thrown when writing to an HTTP response which does not allow contents.
ERR_HTTP_CONTENT_LENGTH_MISMATCH
#
响应正文大小与指定的内容长度标头值不匹配。
¥Response body size doesn't match with the specified content-length header value.
ERR_FS_CP_FIFO_PIPE
#
试图使用 fs.cp()
复制命名管道。
¥An attempt was made to copy a named pipe with fs.cp()
.
ERR_FS_CP_NON_DIR_TO_DIR
#
尝试使用 fs.cp()
将非目录(文件、符号链接等)复制到目录。
¥An attempt was made to copy a non-directory (file, symlink, etc.) to a directory
using fs.cp()
.
ERR_FS_CP_SOCKET
#
试图使用 fs.cp()
复制到套接字。
¥An attempt was made to copy to a socket with fs.cp()
.
ERR_FS_CP_SYMLINK_TO_SUBDIRECTORY
#
当使用 fs.cp()
时,dest
中的符号链接指向 src
的子目录。
¥When using fs.cp()
, a symlink in dest
pointed to a subdirectory
of src
.
ERR_FS_CP_UNKNOWN
#
试图使用 fs.cp()
复制到未知的文件类型。
¥An attempt was made to copy to an unknown file type with fs.cp()
.
ERR_FS_EISDIR
#
路径是目录。
¥Path is a directory.
ERR_FS_FILE_TOO_LARGE
#
已尝试读取大小大于 Buffer
允许的最大大小的文件。
¥An attempt has been made to read a file whose size is larger than the maximum
allowed size for a Buffer
.
ERR_FS_INVALID_SYMLINK_TYPE
#
传给 fs.symlink()
或 fs.symlinkSync()
方法的符号链接类型无效。
¥An invalid symlink type was passed to the fs.symlink()
or
fs.symlinkSync()
methods.
ERR_HTTP_HEADERS_SENT
#
在已发送标头后尝试添加更多标头。
¥An attempt was made to add more headers after the headers had already been sent.
ERR_HTTP_INVALID_HEADER_VALUE
#
指定了无效的 HTTP 标头值。
¥An invalid HTTP header value was specified.
ERR_HTTP_INVALID_STATUS_CODE
#
状态代码超出了常规状态码的范围(100-999)。
¥Status code was outside the regular status code range (100-999).
ERR_HTTP_REQUEST_TIMEOUT
#
客户端没有在允许的时间内发送整个请求。
¥The client has not sent the entire request within the allowed time.
ERR_HTTP_SOCKET_ASSIGNED
#
给定的 ServerResponse
已经分配了一个套接字。
¥The given ServerResponse
was already assigned a socket.
ERR_HTTP_SOCKET_ENCODING
#
根据 RFC 7230 第 3 节,不允许更改套接字编码。
¥Changing the socket encoding is not allowed per RFC 7230 Section 3.
ERR_HTTP_TRAILER_INVALID
#
即使传输编码不支持,也设置了 Trailer
标头。
¥The Trailer
header was set even though the transfer encoding does not support
that.
ERR_HTTP2_ALTSVC_INVALID_ORIGIN
#
HTTP/2 ALTSVC 帧需要有效的来源。
¥HTTP/2 ALTSVC frames require a valid origin.
ERR_HTTP2_ALTSVC_LENGTH
#
HTTP/2 ALTSVC 帧限制为最多 16,382 个有效载荷字节。
¥HTTP/2 ALTSVC frames are limited to a maximum of 16,382 payload bytes.
ERR_HTTP2_CONNECT_AUTHORITY
#
对于使用 CONNECT
方法的 HTTP/2 请求,需要 :authority
伪标头。
¥For HTTP/2 requests using the CONNECT
method, the :authority
pseudo-header
is required.
ERR_HTTP2_CONNECT_PATH
#
对于使用 CONNECT
方法的 HTTP/2 请求,禁止使用 :path
伪标头。
¥For HTTP/2 requests using the CONNECT
method, the :path
pseudo-header is
forbidden.
ERR_HTTP2_CONNECT_SCHEME
#
对于使用 CONNECT
方法的 HTTP/2 请求,禁止使用 :scheme
伪标头。
¥For HTTP/2 requests using the CONNECT
method, the :scheme
pseudo-header is
forbidden.
ERR_HTTP2_ERROR
#
发生了非特定的 HTTP/2 错误。
¥A non-specific HTTP/2 error has occurred.
ERR_HTTP2_GOAWAY_SESSION
#
新的 HTTP/2 流可能不会在 Http2Session
从连接的对等方接收到 GOAWAY
帧后打开。
¥New HTTP/2 Streams may not be opened after the Http2Session
has received a
GOAWAY
frame from the connected peer.
ERR_HTTP2_HEADER_SINGLE_VALUE
#
为只需要一个值的 HTTP/2 标头字段提供了多个值。
¥Multiple values were provided for an HTTP/2 header field that was required to have only a single value.
ERR_HTTP2_HEADERS_AFTER_RESPOND
#
在启动 HTTP/2 响应后指定了额外的标头。
¥An additional headers was specified after an HTTP/2 response was initiated.
ERR_HTTP2_HEADERS_SENT
#
试图发送多个响应头。
¥An attempt was made to send multiple response headers.
ERR_HTTP2_INFO_STATUS_NOT_ALLOWED
#
信息性 HTTP 状态码(1xx
)不能设置为 HTTP/2 响应的响应状态代码。
¥Informational HTTP status codes (1xx
) may not be set as the response status
code on HTTP/2 responses.
ERR_HTTP2_INVALID_CONNECTION_HEADERS
#
HTTP/1 连接特定标头禁止在 HTTP/2 请求和响应中使用。
¥HTTP/1 connection specific headers are forbidden to be used in HTTP/2 requests and responses.
ERR_HTTP2_INVALID_HEADER_VALUE
#
指定了无效的 HTTP/2 标头值。
¥An invalid HTTP/2 header value was specified.
ERR_HTTP2_INVALID_INFO_STATUS
#
指定了无效的 HTTP 信息状态代码。信息状态代码必须是 100
和 199
(含)之间的整数。
¥An invalid HTTP informational status code has been specified. Informational
status codes must be an integer between 100
and 199
(inclusive).
ERR_HTTP2_INVALID_ORIGIN
#
HTTP/2 ORIGIN
帧需要有效的来源。
¥HTTP/2 ORIGIN
frames require a valid origin.
ERR_HTTP2_INVALID_PACKED_SETTINGS_LENGTH
#
传给 http2.getUnpackedSettings()
API 的输入 Buffer
和 Uint8Array
实例的长度必须是 6 的倍数。
¥Input Buffer
and Uint8Array
instances passed to the
http2.getUnpackedSettings()
API must have a length that is a multiple of
six.
ERR_HTTP2_INVALID_PSEUDOHEADER
#
只能使用有效的 HTTP/2 伪标头(:status
、:path
、:authority
、:scheme
和 :method
)。
¥Only valid HTTP/2 pseudoheaders (:status
, :path
, :authority
, :scheme
,
and :method
) may be used.
ERR_HTTP2_INVALID_SESSION
#
对已被销毁的 Http2Session
对象执行了操作。
¥An action was performed on an Http2Session
object that had already been
destroyed.
ERR_HTTP2_INVALID_SETTING_VALUE
#
为 HTTP/2 设置指定了无效值。
¥An invalid value has been specified for an HTTP/2 setting.
ERR_HTTP2_INVALID_STREAM
#
对已被销毁的流执行了操作。
¥An operation was performed on a stream that had already been destroyed.
ERR_HTTP2_MAX_PENDING_SETTINGS_ACK
#
每当一个 HTTP/2 SETTINGS
帧被发送到连接的对端时,对端需要发送确认其已经收到并应用了新的 SETTINGS
。默认情况下,可以在任何给定时间发送最大数量的未确认 SETTINGS
帧。当达到该限制时使用此错误码。
¥Whenever an HTTP/2 SETTINGS
frame is sent to a connected peer, the peer is
required to send an acknowledgment that it has received and applied the new
SETTINGS
. By default, a maximum number of unacknowledged SETTINGS
frames may
be sent at any given time. This error code is used when that limit has been
reached.
ERR_HTTP2_NESTED_PUSH
#
试图从推送流中启动新的推送流。不允许嵌套推送流。
¥An attempt was made to initiate a new push stream from within a push stream. Nested push streams are not permitted.
ERR_HTTP2_NO_MEM
#
使用 http2session.setLocalWindowSize(windowSize)
API 时内存不足。
¥Out of memory when using the http2session.setLocalWindowSize(windowSize)
API.
ERR_HTTP2_NO_SOCKET_MANIPULATION
#
试图直接操作(读取、写入、暂停、恢复等)连接到 Http2Session
的套接字。
¥An attempt was made to directly manipulate (read, write, pause, resume, etc.) a
socket attached to an Http2Session
.
ERR_HTTP2_ORIGIN_LENGTH
#
HTTP/2 ORIGIN
帧的长度限制为 16382 字节。
¥HTTP/2 ORIGIN
frames are limited to a length of 16382 bytes.
ERR_HTTP2_OUT_OF_STREAMS
#
在单个 HTTP/2 会话上创建的流数达到了最大限制。
¥The number of streams created on a single HTTP/2 session reached the maximum limit.
ERR_HTTP2_PAYLOAD_FORBIDDEN
#
已为禁止负载的 HTTP 响应码指定了消息负载。
¥A message payload was specified for an HTTP response code for which a payload is forbidden.
ERR_HTTP2_PING_CANCEL
#
HTTP/2 发送回显信息被取消。
¥An HTTP/2 ping was canceled.
ERR_HTTP2_PING_LENGTH
#
HTTP/2 发送回显信息负载的长度必须正好是 8 个字节。
¥HTTP/2 ping payloads must be exactly 8 bytes in length.
ERR_HTTP2_PSEUDOHEADER_NOT_ALLOWED
#
HTTP/2 伪标头使用不当。伪标头是以 :
前缀开头的标头键名。
¥An HTTP/2 pseudo-header has been used inappropriately. Pseudo-headers are header
key names that begin with the :
prefix.
ERR_HTTP2_PUSH_DISABLED
#
尝试创建推送流,但已被客户端禁用。
¥An attempt was made to create a push stream, which had been disabled by the client.
ERR_HTTP2_SEND_FILE
#
尝试使用 Http2Stream.prototype.responseWithFile()
API 发送目录。
¥An attempt was made to use the Http2Stream.prototype.responseWithFile()
API to
send a directory.
ERR_HTTP2_SEND_FILE_NOSEEK
#
尝试使用 Http2Stream.prototype.responseWithFile()
API 发送常规文件以外的内容,但提供了 offset
或 length
选项。
¥An attempt was made to use the Http2Stream.prototype.responseWithFile()
API to
send something other than a regular file, but offset
or length
options were
provided.
ERR_HTTP2_SESSION_ERROR
#
Http2Session
以非零错误码关闭。
¥The Http2Session
closed with a non-zero error code.
ERR_HTTP2_SETTINGS_CANCEL
#
Http2Session
设置取消。
¥The Http2Session
settings canceled.
ERR_HTTP2_SOCKET_BOUND
#
试图将 Http2Session
对象连接到已经绑定到另一个 Http2Session
对象的 net.Socket
或 tls.TLSSocket
。
¥An attempt was made to connect a Http2Session
object to a net.Socket
or
tls.TLSSocket
that had already been bound to another Http2Session
object.
ERR_HTTP2_SOCKET_UNBOUND
#
尝试使用已关闭的 Http2Session
的 socket
属性。
¥An attempt was made to use the socket
property of an Http2Session
that
has already been closed.
ERR_HTTP2_STATUS_101
#
在 HTTP/2 中禁止使用 101
信息状态码。
¥Use of the 101
Informational status code is forbidden in HTTP/2.
ERR_HTTP2_STATUS_INVALID
#
指定了无效的 HTTP 状态码。状态码必须是介于 100
和 599
(含)之间的整数。
¥An invalid HTTP status code has been specified. Status codes must be an integer
between 100
and 599
(inclusive).
ERR_HTTP2_STREAM_CANCEL
#
在将任何数据传输到连接的对等方之前,Http2Stream
已被销毁。
¥An Http2Stream
was destroyed before any data was transmitted to the connected
peer.
ERR_HTTP2_STREAM_ERROR
#
在 RST_STREAM
帧中指定了非零错误码。
¥A non-zero error code was been specified in an RST_STREAM
frame.
ERR_HTTP2_STREAM_SELF_DEPENDENCY
#
当在为 HTTP/2 流设置优先级时,该流可能被标记为父流的依赖。当试图标记流并依赖于它自己时,将使用此错误码。
¥When setting the priority for an HTTP/2 stream, the stream may be marked as a dependency for a parent stream. This error code is used when an attempt is made to mark a stream and dependent of itself.
ERR_HTTP2_TOO_MANY_INVALID_FRAMES
#
已超出通过 maxSessionInvalidFrames
选项指定的对等方发送的可接受的无效 HTTP/2 协议帧的限制。
¥The limit of acceptable invalid HTTP/2 protocol frames sent by the peer,
as specified through the maxSessionInvalidFrames
option, has been exceeded.
ERR_HTTP2_TRAILERS_ALREADY_SENT
#
已在 Http2Stream
上发送了尾随标头。
¥Trailing headers have already been sent on the Http2Stream
.
ERR_HTTP2_TRAILERS_NOT_READY
#
在 Http2Stream
对象上触发 'wantTrailers'
事件之后,才能调用 http2stream.sendTrailers()
方法。只有为 Http2Stream
设置了 waitForTrailers
选项,才会触发 'wantTrailers'
事件。
¥The http2stream.sendTrailers()
method cannot be called until after the
'wantTrailers'
event is emitted on an Http2Stream
object. The
'wantTrailers'
event will only be emitted if the waitForTrailers
option
is set for the Http2Stream
.
ERR_HTTP2_UNSUPPORTED_PROTOCOL
#
http2.connect()
传入的网址使用除 http:
或 https:
以外的任何协议。
¥http2.connect()
was passed a URL that uses any protocol other than http:
or
https:
.
ERR_ILLEGAL_CONSTRUCTOR
#
尝试使用非公共构造函数构造对象。
¥An attempt was made to construct an object using a non-public constructor.
ERR_IMPORT_ASSERTION_TYPE_FAILED
#
提供了导入 type
属性,但指定的模块属于不同类型。
¥An import type
attribute was provided, but the specified module is of a
different type.
ERR_IMPORT_ASSERTION_TYPE_MISSING
#
缺少导入属性,导致无法导入指定的模块。
¥An import attribute is missing, preventing the specified module to be imported.
ERR_IMPORT_ASSERTION_TYPE_UNSUPPORTED
#
此版本的 Node.js 不支持导入属性。
¥An import attribute is not supported by this version of Node.js.
ERR_IMPORT_ATTRIBUTE_UNSUPPORTED
#
此版本的 Node.js 不支持导入属性。
¥An import attribute is not supported by this version of Node.js.
ERR_INCOMPATIBLE_OPTION_PAIR
#
选项对彼此不兼容,不能同时使用。
¥An option pair is incompatible with each other and cannot be used at the same time.
ERR_INPUT_TYPE_NOT_ALLOWED
#
¥Stability: 1 - Experimental
--input-type
标志用于尝试执行文件。此标志只能用于通过 --eval
、--print
或 STDIN
输入。
¥The --input-type
flag was used to attempt to execute a file. This flag can
only be used with input via --eval
, --print
, or STDIN
.
ERR_INSPECTOR_ALREADY_ACTIVATED
#
在使用 node:inspector
模块时,当检查器已经开始监听端口时尝试激活。在不同地址上激活之前使用 inspector.close()
。
¥While using the node:inspector
module, an attempt was made to activate the
inspector when it already started to listen on a port. Use inspector.close()
before activating it on a different address.
ERR_INSPECTOR_ALREADY_CONNECTED
#
在使用 node:inspector
模块时,当检查器已经连接时尝试连接。
¥While using the node:inspector
module, an attempt was made to connect when the
inspector was already connected.
ERR_INSPECTOR_CLOSED
#
在使用 node:inspector
模块时,在会话已经关闭后尝试使用检查器。
¥While using the node:inspector
module, an attempt was made to use the
inspector after the session had already closed.
ERR_INSPECTOR_COMMAND
#
通过 node:inspector
模块触发命令时发生错误。
¥An error occurred while issuing a command via the node:inspector
module.
ERR_INSPECTOR_NOT_ACTIVE
#
当调用 inspector.waitForDebugger()
时,inspector
未激活。
¥The inspector
is not active when inspector.waitForDebugger()
is called.
ERR_INSPECTOR_NOT_AVAILABLE
#
node:inspector
模块无法使用。
¥The node:inspector
module is not available for use.
ERR_INSPECTOR_NOT_CONNECTED
#
在使用 node:inspector
模块时,尝试在连接前使用检查器。
¥While using the node:inspector
module, an attempt was made to use the
inspector before it was connected.
ERR_INSPECTOR_NOT_WORKER
#
在主线程上调用了只能从工作线程使用的 API。
¥An API was called on the main thread that can only be used from the worker thread.
ERR_INTERNAL_ASSERTION
#
Node.js 中存在错误或 Node.js 内部使用不正确。要修复该错误,请在 https://github.com/nodejs/node/issues 打开一个问题。
¥There was a bug in Node.js or incorrect usage of Node.js internals. To fix the error, open an issue at https://github.com/nodejs/node/issues.
ERR_INVALID_ADDRESS_FAMILY
#
Node.js API 无法识别提供的地址族。
¥The provided address family is not understood by the Node.js API.
ERR_INVALID_ARG_TYPE
#
传给 Node.js API 的参数类型错误。
¥An argument of the wrong type was passed to a Node.js API.
ERR_INVALID_ARG_VALUE
#
为给定参数传入了无效或不受支持的值。
¥An invalid or unsupported value was passed for a given argument.
ERR_INVALID_ASYNC_ID
#
使用 AsyncHooks
传入了无效的 asyncId
或 triggerAsyncId
。小于 -1 的标识不应该发生。
¥An invalid asyncId
or triggerAsyncId
was passed using AsyncHooks
. An id
less than -1 should never happen.
ERR_INVALID_BUFFER_SIZE
#
在 Buffer
上执行了交换,但其大小与操作不兼容。
¥A swap was performed on a Buffer
but its size was not compatible with the
operation.
ERR_INVALID_CHAR
#
在标头中检测到无效字符。
¥Invalid characters were detected in headers.
ERR_INVALID_CURSOR_POS
#
给定流上的游标不能移动到没有指定列的指定行。
¥A cursor on a given stream cannot be moved to a specified row without a specified column.
ERR_INVALID_FD
#
文件描述符 ('fd') 无效(例如,它是负值)。
¥A file descriptor ('fd') was not valid (e.g. it was a negative value).
ERR_INVALID_FD_TYPE
#
文件描述符 ('fd') 类型无效。
¥A file descriptor ('fd') type was not valid.
ERR_INVALID_FILE_URL_HOST
#
使用 file:
网址的 Node.js API(例如 fs
模块中的某些函数)遇到了主机不兼容的文件网址。这种情况只能发生在只支持 localhost
或空主机的类 Unix 系统上。
¥A Node.js API that consumes file:
URLs (such as certain functions in the
fs
module) encountered a file URL with an incompatible host. This
situation can only occur on Unix-like systems where only localhost
or an empty
host is supported.
ERR_INVALID_FILE_URL_PATH
#
使用 file:
网址的 Node.js API(例如 fs
模块中的某些函数)遇到路径不兼容的文件网址。确定是否可以使用路径的确切语义是平台相关的。
¥A Node.js API that consumes file:
URLs (such as certain functions in the
fs
module) encountered a file URL with an incompatible path. The exact
semantics for determining whether a path can be used is platform-dependent.
ERR_INVALID_HANDLE_TYPE
#
试图通过 IPC 通信通道将不受支持的 "handle" 发送到子进程。有关详细信息,请参阅 subprocess.send()
和 process.send()
。
¥An attempt was made to send an unsupported "handle" over an IPC communication
channel to a child process. See subprocess.send()
and process.send()
for more information.
ERR_INVALID_HTTP_TOKEN
#
提供了无效的 HTTP 令牌。
¥An invalid HTTP token was supplied.
ERR_INVALID_IP_ADDRESS
#
IP 地址无效。
¥An IP address is not valid.
ERR_INVALID_MIME_SYNTAX
#
MIME 语法无效。
¥The syntax of a MIME is not valid.
ERR_INVALID_MODULE
#
试图加载不存在或无效的模块。
¥An attempt was made to load a module that does not exist or was otherwise not valid.
ERR_INVALID_MODULE_SPECIFIER
#
导入的模块字符串是无效的网址、包名称、或包的子路径说明符。
¥The imported module string is an invalid URL, package name, or package subpath specifier.
ERR_INVALID_OBJECT_DEFINE_PROPERTY
#
在对象的属性上设置无效属性时出错。
¥An error occurred while setting an invalid attribute on the property of an object.
ERR_INVALID_PACKAGE_CONFIG
#
无效的 package.json
文件解析失败。
¥An invalid package.json
file failed parsing.
ERR_INVALID_PACKAGE_TARGET
#
package.json
"exports"
字段包含用于尝试模块解析的无效目标映射值。
¥The package.json
"exports"
field contains an invalid target mapping
value for the attempted module resolution.
ERR_INVALID_PERFORMANCE_MARK
#
在使用性能计时 API (perf_hooks
) 时,性能标记无效。
¥While using the Performance Timing API (perf_hooks
), a performance mark is
invalid.
ERR_INVALID_PROTOCOL
#
无效的 options.protocol
被传给了 http.request()
。
¥An invalid options.protocol
was passed to http.request()
.
ERR_INVALID_REPL_EVAL_CONFIG
#
breakEvalOnSigint
和 eval
选项都在 REPL
配置中设置,这是不支持的。
¥Both breakEvalOnSigint
and eval
options were set in the REPL
config,
which is not supported.
ERR_INVALID_REPL_INPUT
#
输入不能在 REPL
中使用。REPL
文档中描述了使用此错误的条件。
¥The input may not be used in the REPL
. The conditions under which this
error is used are described in the REPL
documentation.
ERR_INVALID_RETURN_PROPERTY
#
如果函数选项在执行时没有为其返回的对象属性之一提供有效值时,则抛出错误。
¥Thrown in case a function option does not provide a valid value for one of its returned object properties on execution.
ERR_INVALID_RETURN_PROPERTY_VALUE
#
如果函数选项在执行时没有为其返回的对象属性之一提供预期值类型时,则抛出错误。
¥Thrown in case a function option does not provide an expected value type for one of its returned object properties on execution.
ERR_INVALID_RETURN_VALUE
#
如果函数选项在执行时没有返回预期的值类型时(例如当函数应该返回 promise),则抛出错误。
¥Thrown in case a function option does not return an expected value type on execution, such as when a function is expected to return a promise.
ERR_INVALID_STATE
#
表示由于状态无效而无法完成操作。例如,对象可能已经被销毁,或者可能正在执行另一个操作。
¥Indicates that an operation cannot be completed due to an invalid state. For instance, an object may have already been destroyed, or may be performing another operation.
ERR_INVALID_SYNC_FORK_INPUT
#
将 Buffer
、TypedArray
、DataView
或 string
作为标准输入输出提供给异步的衍生。有关更多信息,请参阅 child_process
模块的文档。
¥A Buffer
, TypedArray
, DataView
, or string
was provided as stdio input to
an asynchronous fork. See the documentation for the child_process
module
for more information.
ERR_INVALID_THIS
#
使用不兼容的 this
值调用了 Node.js API 函数
¥A Node.js API function was called with an incompatible this
value.
const urlSearchParams = new URLSearchParams('foo=bar&baz=new');
const buf = Buffer.alloc(1);
urlSearchParams.has.call(buf, 'foo');
// Throws a TypeError with code 'ERR_INVALID_THIS'
ERR_INVALID_TRANSFER_OBJECT
#
无效的传输对象被传给 postMessage()
。
¥An invalid transfer object was passed to postMessage()
.
ERR_INVALID_TUPLE
#
提供给 WHATWG URLSearchParams
构造函数 的 iterable
中的元素不代表 [name, value]
元组 - 也就是说,如果一个元素不可迭代,或者不完全由两个元素组成。
¥An element in the iterable
provided to the WHATWG
URLSearchParams
constructor did not
represent a [name, value]
tuple – that is, if an element is not iterable, or
does not consist of exactly two elements.
ERR_INVALID_URI
#
传入了无效的网址。
¥An invalid URI was passed.
ERR_INVALID_URL
#
无效的 URL 已传递到 WHATWG URL
构造函数 或旧版 url.parse()
进行解析。抛出的错误对象通常有附加的属性 'input'
,其中包含解析失败的网址。
¥An invalid URL was passed to the WHATWG URL
constructor or the legacy url.parse()
to be parsed.
The thrown error object typically has an additional property 'input'
that
contains the URL that failed to parse.
ERR_INVALID_URL_SCHEME
#
试图将不兼容方案(协议)的网址用于特定目的。它仅用于 fs
模块中的 WHATWG URL API 支持(仅接受具有 'file'
方案的 URL),但将来也可能用于其他 Node.js API。
¥An attempt was made to use a URL of an incompatible scheme (protocol) for a
specific purpose. It is only used in the WHATWG URL API support in the
fs
module (which only accepts URLs with 'file'
scheme), but may be used
in other Node.js APIs as well in the future.
ERR_IPC_CHANNEL_CLOSED
#
尝试使用已关闭的进程间通信通道。
¥An attempt was made to use an IPC communication channel that was already closed.
ERR_IPC_DISCONNECTED
#
试图断开已经断开的进程间通信通道。有关更多信息,请参阅 child_process
模块的文档。
¥An attempt was made to disconnect an IPC communication channel that was already
disconnected. See the documentation for the child_process
module
for more information.
ERR_IPC_ONE_PIPE
#
尝试使用多个进程间通信通道创建子 Node.js 进程。有关更多信息,请参阅 child_process
模块的文档。
¥An attempt was made to create a child Node.js process using more than one IPC
communication channel. See the documentation for the child_process
module
for more information.
ERR_IPC_SYNC_FORK
#
尝试使用同步衍生的 Node.js 进程打开进程间通信通道。有关更多信息,请参阅 child_process
模块的文档。
¥An attempt was made to open an IPC communication channel with a synchronously
forked Node.js process. See the documentation for the child_process
module
for more information.
ERR_LOADER_CHAIN_INCOMPLETE
#
返回 ESM 加载器钩子,没有调用 next()
,也没有明确触发短路信号。
¥An ESM loader hook returned without calling next()
and without explicitly
signaling a short circuit.
ERR_MANIFEST_ASSERT_INTEGRITY
#
尝试加载资源,但该资源与策略清单定义的完整性不匹配。有关详细信息,请参阅 policy 清单的文档。
¥An attempt was made to load a resource, but the resource did not match the integrity defined by the policy manifest. See the documentation for policy manifests for more information.
ERR_MANIFEST_DEPENDENCY_MISSING
#
已尝试加载资源,但该资源未列为尝试加载它的位置的依赖。有关详细信息,请参阅 policy 清单的文档。
¥An attempt was made to load a resource, but the resource was not listed as a dependency from the location that attempted to load it. See the documentation for policy manifests for more information.
ERR_MANIFEST_INTEGRITY_MISMATCH
#
已尝试加载策略清单,但该清单包含多个彼此不匹配的资源条目。更新清单条目以解决此错误。有关详细信息,请参阅 policy 清单的文档。
¥An attempt was made to load a policy manifest, but the manifest had multiple entries for a resource which did not match each other. Update the manifest entries to match in order to resolve this error. See the documentation for policy manifests for more information.
ERR_MANIFEST_INVALID_RESOURCE_FIELD
#
策略清单资源的其中一个字段的值无效。更新清单条目以解决此错误。有关详细信息,请参阅 policy 清单的文档。
¥A policy manifest resource had an invalid value for one of its fields. Update the manifest entry to match in order to resolve this error. See the documentation for policy manifests for more information.
ERR_MANIFEST_INVALID_SPECIFIER
#
策略清单资源的依赖映射之一具有无效值。更新清单条目以匹配以解决此错误。有关详细信息,请参阅 policy 清单的文档。
¥A policy manifest resource had an invalid value for one of its dependency mappings. Update the manifest entry to match to resolve this error. See the documentation for policy manifests for more information.
ERR_MANIFEST_PARSE_POLICY
#
已尝试加载策略清单,但无法解析该清单。有关详细信息,请参阅 policy 清单的文档。
¥An attempt was made to load a policy manifest, but the manifest was unable to be parsed. See the documentation for policy manifests for more information.
ERR_MANIFEST_TDZ
#
已尝试从策略清单中读取,但清单初始化尚未发生。这可能是 Node.js 中的错误。
¥An attempt was made to read from a policy manifest, but the manifest initialization has not yet taken place. This is likely a bug in Node.js.
ERR_MANIFEST_UNKNOWN_ONERROR
#
已加载策略清单,但其 "onerror" 行为具有未知值。有关详细信息,请参阅 policy 清单的文档。
¥A policy manifest was loaded, but had an unknown value for its "onerror" behavior. See the documentation for policy manifests for more information.
ERR_MEMORY_ALLOCATION_FAILED
#
尝试分配内存(通常在 C++ 层),但是失败。
¥An attempt was made to allocate memory (usually in the C++ layer) but it failed.
ERR_MESSAGE_TARGET_CONTEXT_UNAVAILABLE
#
无法在目标 vm Context
中反序列化发布到 MessagePort
的消息。目前并非所有 Node.js 对象都可以在任何上下文中成功实例化,在这种情况下,尝试使用 postMessage()
传输它们可能会在接收端失败。
¥A message posted to a MessagePort
could not be deserialized in the target
vm Context
. Not all Node.js objects can be successfully instantiated in
any context at this time, and attempting to transfer them using postMessage()
can fail on the receiving side in that case.
ERR_METHOD_NOT_IMPLEMENTED
#
需要方法,但未实现。
¥A method is required but not implemented.
ERR_MISSING_ARGS
#
未传入 Node.js API 的必需参数。这仅用于严格遵守 API 规范(在某些情况下可能接受 func(undefined)
但不接受 func()
)。在大多数原生 Node.js API 中,func(undefined)
和 func()
的处理方式相同,可以使用 ERR_INVALID_ARG_TYPE
错误码代替。
¥A required argument of a Node.js API was not passed. This is only used for
strict compliance with the API specification (which in some cases may accept
func(undefined)
but not func()
). In most native Node.js APIs,
func(undefined)
and func()
are treated identically, and the
ERR_INVALID_ARG_TYPE
error code may be used instead.
ERR_MISSING_OPTION
#
对于接受选项对象的 API,某些选项可能是强制性的。如果缺少必需的选项,则会抛出此代码。
¥For APIs that accept options objects, some options might be mandatory. This code is thrown if a required option is missing.
ERR_MISSING_PASSPHRASE
#
已尝试在未指定密码的情况下读取加密密钥。
¥An attempt was made to read an encrypted key without specifying a passphrase.
ERR_MISSING_PLATFORM_FOR_WORKER
#
此 Node.js 实例使用的 V8 平台不支持创建工作线程。这是由于缺乏对工作线程的嵌入支持造成的。特别是,此错误不会发生在 Node.js 的标准构建中。
¥The V8 platform used by this instance of Node.js does not support creating Workers. This is caused by lack of embedder support for Workers. In particular, this error will not occur with standard builds of Node.js.
ERR_MISSING_TRANSFERABLE_IN_TRANSFER_LIST
#
需要在 transferList
参数中显式列出的对象在传给 postMessage()
调用的对象中,但未在 transferList
中为该调用提供。通常,这是 MessagePort
。
¥An object that needs to be explicitly listed in the transferList
argument
is in the object passed to a postMessage()
call, but is not provided
in the transferList
for that call. Usually, this is a MessagePort
.
在 v15.0.0 之前的 Node.js 版本中,这里使用的错误码是 ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST
。但是,可传输对象类型集已扩展到涵盖比 MessagePort
更多的类型。
¥In Node.js versions prior to v15.0.0, the error code being used here was
ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST
. However, the set of
transferable object types has been expanded to cover more types than
MessagePort
.
ERR_MODULE_NOT_FOUND
#
当尝试 import
操作或加载程序入口点时,ECMAScript 模块加载器无法解析模块文件。
¥A module file could not be resolved by the ECMAScript modules loader while
attempting an import
operation or when loading the program entry point.
ERR_MULTIPLE_CALLBACK
#
回调被多次调用。
¥A callback was called more than once.
回调几乎总是意味着只被调用一次,因为查询可以被履行或被拒绝,但不能同时被执行。后者可以通过多次调用回调来实现。
¥A callback is almost always meant to only be called once as the query can either be fulfilled or rejected but not both at the same time. The latter would be possible by calling a callback more than once.
ERR_NAPI_CONS_FUNCTION
#
在使用 Node-API
时,传入的构造函数不是函数。
¥While using Node-API
, a constructor passed was not a function.
ERR_NAPI_INVALID_DATAVIEW_ARGS
#
在调用 napi_create_dataview()
时,给定的 offset
超出了数据视图的边界或 offset + length
大于给定的 buffer
的长度。
¥While calling napi_create_dataview()
, a given offset
was outside the bounds
of the dataview or offset + length
was larger than a length of given buffer
.
ERR_NAPI_INVALID_TYPEDARRAY_ALIGNMENT
#
在调用 napi_create_typedarray()
时,提供的 offset
不是元素大小的倍数
¥While calling napi_create_typedarray()
, the provided offset
was not a
multiple of the element size.
ERR_NAPI_INVALID_TYPEDARRAY_LENGTH
#
在调用 napi_create_typedarray()
时,(length * size_of_element) + byte_offset
大于给定的 buffer
的长度。
¥While calling napi_create_typedarray()
, (length * size_of_element) + byte_offset
was larger than the length of given buffer
.
ERR_NAPI_TSFN_CALL_JS
#
调用线程安全函数的 JavaScript 部分时出错。
¥An error occurred while invoking the JavaScript portion of the thread-safe function.
ERR_NAPI_TSFN_GET_UNDEFINED
#
尝试检索 JavaScript undefined
值时出错。
¥An error occurred while attempting to retrieve the JavaScript undefined
value.
ERR_NAPI_TSFN_START_IDLE_LOOP
#
在主线程上,值从空闲循环中与线程安全函数关联的队列中删除。此错误表示尝试启动循环时发生错误。
¥On the main thread, values are removed from the queue associated with the thread-safe function in an idle loop. This error indicates that an error has occurred when attempting to start the loop.
ERR_NAPI_TSFN_STOP_IDLE_LOOP
#
一旦队列中没有更多的条目,则空闲循环必须暂停。此错误表明空闲循环未能停止
¥Once no more items are left in the queue, the idle loop must be suspended. This error indicates that the idle loop has failed to stop.
ERR_NOT_BUILDING_SNAPSHOT
#
尝试使用只能在构建 V8 启动快照时使用的操作,即使 Node.js 没有构建一个。
¥An attempt was made to use operations that can only be used when building V8 startup snapshot even though Node.js isn't building one.
ERR_NO_CRYPTO
#
尝试使用加密特性,而 Node.js 没有使用 OpenSSL 加密支持进行编译。
¥An attempt was made to use crypto features while Node.js was not compiled with OpenSSL crypto support.
ERR_NO_ICU
#
已尝试使用需要 ICU 的功能,但 Node.js 未使用 ICU 支持进行编译。
¥An attempt was made to use features that require ICU, but Node.js was not compiled with ICU support.
ERR_NON_CONTEXT_AWARE_DISABLED
#
在不允许加载的进程中加载了非上下文感知的原生插件。
¥A non-context-aware native addon was loaded in a process that disallows them.
ERR_OUT_OF_RANGE
#
给定的值超出了可接受的范围。
¥A given value is out of the accepted range.
ERR_PACKAGE_IMPORT_NOT_DEFINED
#
package.json
"imports"
字段未定义给定的内部包说明符映射。
¥The package.json
"imports"
field does not define the given internal
package specifier mapping.
ERR_PACKAGE_PATH_NOT_EXPORTED
#
package.json
"exports"
字段没有导出请求的子路径。因为导出是封装的,没有导出的私有内部模块无法通过包解析导入,除非使用绝对网址。
¥The package.json
"exports"
field does not export the requested subpath.
Because exports are encapsulated, private internal modules that are not exported
cannot be imported through the package resolution, unless using an absolute URL.
ERR_PARSE_ARGS_INVALID_OPTION_VALUE
#
当 strict
设置为 true
时,如果为 <string> 类型的选项提供了 <boolean> 值,或者为 <boolean> 类型的选项提供了 <string> 值,则由 util.parseArgs()
抛出异常。
¥When strict
set to true
, thrown by util.parseArgs()
if a <boolean>
value is provided for an option of type <string>, or if a <string>
value is provided for an option of type <boolean>.
ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL
#
当提供位置参数并且 allowPositionals
设置为 false
时,由 util.parseArgs()
抛出。
¥Thrown by util.parseArgs()
, when a positional argument is provided and
allowPositionals
is set to false
.
ERR_PARSE_ARGS_UNKNOWN_OPTION
#
当 strict
设置为 true
时,如果 options
中没有配置参数,则由 util.parseArgs()
抛出异常。
¥When strict
set to true
, thrown by util.parseArgs()
if an argument
is not configured in options
.
ERR_PERFORMANCE_INVALID_TIMESTAMP
#
为性能标记或度量提供了无效的时间戳值。
¥An invalid timestamp value was provided for a performance mark or measure.
ERR_PERFORMANCE_MEASURE_INVALID_OPTIONS
#
为性能度量提供了无效选项。
¥Invalid options were provided for a performance measure.
ERR_PROTO_ACCESS
#
已禁止使用 --disable-proto=throw
访问 Object.prototype.__proto__
。Object.getPrototypeOf
和 Object.setPrototypeOf
应该用于获取和设置对象的原型。
¥Accessing Object.prototype.__proto__
has been forbidden using
--disable-proto=throw
. Object.getPrototypeOf
and
Object.setPrototypeOf
should be used to get and set the prototype of an
object.
ERR_REQUIRE_ESM
#
¥Stability: 1 - Experimental
已尝试对 require()
和 ES 模块 进行操作。
¥An attempt was made to require()
an ES Module.
ERR_SCRIPT_EXECUTION_INTERRUPTED
#
脚本执行被 SIGINT
中断(例如按下了 Ctrl+C)
¥Script execution was interrupted by SIGINT
(For
example, Ctrl+C was pressed.)
ERR_SCRIPT_EXECUTION_TIMEOUT
#
脚本执行超时,可能是由于正在执行的脚本中存在错误。
¥Script execution timed out, possibly due to bugs in the script being executed.
ERR_SERVER_ALREADY_LISTEN
#
当 net.Server
已经在监听时调用了 server.listen()
方法。这适用于 net.Server
的所有实例,包括 HTTP、HTTPS 和 HTTP/2 Server
实例。
¥The server.listen()
method was called while a net.Server
was already
listening. This applies to all instances of net.Server
, including HTTP, HTTPS,
and HTTP/2 Server
instances.
ERR_SERVER_NOT_RUNNING
#
当 net.Server
未运行时调用了 server.close()
方法。这适用于 net.Server
的所有实例,包括 HTTP、HTTPS 和 HTTP/2 Server
实例。
¥The server.close()
method was called when a net.Server
was not
running. This applies to all instances of net.Server
, including HTTP, HTTPS,
and HTTP/2 Server
instances.
ERR_SOCKET_ALREADY_BOUND
#
试图绑定已经绑定的套接字。
¥An attempt was made to bind a socket that has already been bound.
ERR_SOCKET_BAD_BUFFER_SIZE
#
为 dgram.createSocket()
中的 recvBufferSize
或 sendBufferSize
选项传入了无效的(负数的)大小。
¥An invalid (negative) size was passed for either the recvBufferSize
or
sendBufferSize
options in dgram.createSocket()
.
ERR_SOCKET_BAD_PORT
#
期望端口 >= 0 且 < 65536 的 API 函数收到无效值。
¥An API function expecting a port >= 0 and < 65536 received an invalid value.
ERR_SOCKET_BAD_TYPE
#
需要套接字类型(udp4
或 udp6
)的 API 函数收到无效值。
¥An API function expecting a socket type (udp4
or udp6
) received an invalid
value.
ERR_SOCKET_BUFFER_SIZE
#
在使用 dgram.createSocket()
时,无法确定接收或发送 Buffer
的大小。
¥While using dgram.createSocket()
, the size of the receive or send Buffer
could not be determined.
ERR_SOCKET_CLOSED
#
试图在已经关闭的套接字上进行操作。
¥An attempt was made to operate on an already closed socket.
ERR_SOCKET_CLOSED_BEFORE_CONNECTION
#
在连接套接字上调用 net.Socket.write()
时套接字在连接建立之前关闭。
¥When calling net.Socket.write()
on a connecting socket and the socket was
closed before the connection was established.
ERR_SOCKET_DGRAM_IS_CONNECTED
#
在已连接的套接字上进行了 dgram.connect()
调用。
¥A dgram.connect()
call was made on an already connected socket.
ERR_SOCKET_DGRAM_NOT_CONNECTED
#
在断开连接的套接字上进行了 dgram.disconnect()
或 dgram.remoteAddress()
调用。
¥A dgram.disconnect()
or dgram.remoteAddress()
call was made on a
disconnected socket.
ERR_SOCKET_DGRAM_NOT_RUNNING
#
进行了调用,并且 UDP 子系统没有运行。
¥A call was made and the UDP subsystem was not running.
ERR_SRI_PARSE
#
为子资源完整性检查提供了字符串,但无法解析。通过查看 子资源完整性规范 检查完整性属性的格式。
¥A string was provided for a Subresource Integrity check, but was unable to be parsed. Check the format of integrity attributes by looking at the Subresource Integrity specification.
ERR_STREAM_ALREADY_FINISHED
#
调用的流方法无法完成,因为流已完成
¥A stream method was called that cannot complete because the stream was finished.
ERR_STREAM_CANNOT_PIPE
#
试图在 Writable
流上调用 stream.pipe()
¥An attempt was made to call stream.pipe()
on a Writable
stream.
ERR_STREAM_DESTROYED
#
调用了无法完成的流方法,因为使用 stream.destroy()
销毁了该流。
¥A stream method was called that cannot complete because the stream was
destroyed using stream.destroy()
.
ERR_STREAM_NULL_VALUES
#
试图用 null
块调用 stream.write()
。
¥An attempt was made to call stream.write()
with a null
chunk.
ERR_STREAM_PREMATURE_CLOSE
#
stream.finished()
和 stream.pipeline()
返回的错误,当流或管道以非正常方式结束且没有显式错误时。
¥An error returned by stream.finished()
and stream.pipeline()
, when a stream
or a pipeline ends non gracefully with no explicit error.
ERR_STREAM_PUSH_AFTER_EOF
#
在将 null
(EOF)推送到流后,尝试调用 stream.push()
。
¥An attempt was made to call stream.push()
after a null
(EOF) had been
pushed to the stream.
ERR_STREAM_UNSHIFT_AFTER_END_EVENT
#
在触发 'end'
事件后尝试调用 stream.unshift()
。
¥An attempt was made to call stream.unshift()
after the 'end'
event was
emitted.
ERR_STREAM_WRAP
#
如果在套接字上设置了字符串解码器或解码器在 objectMode
中,则防止中止。
¥Prevents an abort if a string decoder was set on the Socket or if the decoder
is in objectMode
.
const Socket = require('node:net').Socket;
const instance = new Socket();
instance.setEncoding('utf8');
ERR_STREAM_WRITE_AFTER_END
#
在调用 stream.end()
后尝试调用 stream.write()
。
¥An attempt was made to call stream.write()
after stream.end()
has been
called.
ERR_STRING_TOO_LONG
#
尝试创建长度超过最大允许长度的字符串。
¥An attempt has been made to create a string longer than the maximum allowed length.
ERR_SYNTHETIC
#
用于捕获诊断报告调用堆栈的人为错误对象。
¥An artificial error object used to capture the call stack for diagnostic reports.
ERR_SYSTEM_ERROR
#
Node.js 进程中发生了未指定或非特定的系统错误。错误对象将具有带有附加详细信息的 err.info
对象属性。
¥An unspecified or non-specific system error has occurred within the Node.js
process. The error object will have an err.info
object property with
additional details.
ERR_TAP_LEXER_ERROR
#
代表失败的词法分析器状态的错误。
¥An error representing a failing lexer state.
ERR_TAP_PARSER_ERROR
#
表示解析器状态失败的错误。有关导致错误的令牌的其他信息可通过 cause
属性获得。
¥An error representing a failing parser state. Additional information about
the token causing the error is available via the cause
property.
ERR_TAP_VALIDATION_ERROR
#
此错误表示 TAP 验证失败。
¥This error represents a failed TAP validation.
ERR_TEST_FAILURE
#
此错误表示测试失败。有关失败的其他信息可通过 cause
属性获得。failureType
属性指定发生故障时测试正在做什么。
¥This error represents a failed test. Additional information about the failure
is available via the cause
property. The failureType
property specifies
what the test was doing when the failure occurred.
ERR_TLS_ALPN_CALLBACK_INVALID_RESULT
#
当 ALPNCallback
返回的值不在客户端提供的 ALPN 协议列表中时,会引发此错误。
¥This error is thrown when an ALPNCallback
returns a value that is not in the
list of ALPN protocols offered by the client.
ERR_TLS_ALPN_CALLBACK_WITH_PROTOCOLS
#
如果 TLS 选项同时包含 ALPNProtocols
和 ALPNCallback
,则创建 TLSServer
时会引发此错误。这些选项是互斥的。
¥This error is thrown when creating a TLSServer
if the TLS options include
both ALPNProtocols
and ALPNCallback
. These options are mutually exclusive.
ERR_TLS_CERT_ALTNAME_FORMAT
#
如果用户提供的 subjectaltname
属性违反编码规则,则 checkServerIdentity
会抛出此错误。Node.js 本身生成的证书对象始终符合编码规则,永远不会出现此错误。
¥This error is thrown by checkServerIdentity
if a user-supplied
subjectaltname
property violates encoding rules. Certificate objects produced
by Node.js itself always comply with encoding rules and will never cause
this error.
ERR_TLS_CERT_ALTNAME_INVALID
#
在使用 TLS 时,对等方的主机名/IP 与其证书中的任何 subjectAltNames
都不匹配。
¥While using TLS, the host name/IP of the peer did not match any of the
subjectAltNames
in its certificate.
ERR_TLS_DH_PARAM_SIZE
#
在使用 TLS 时,为 Diffie-Hellman(DH
)密钥协商协议提供的参数太小。默认情况下,密钥长度必须大于或等于 1024 位以避免漏洞,尽管强烈建议使用 2048 位或更大以增强安全性。
¥While using TLS, the parameter offered for the Diffie-Hellman (DH
)
key-agreement protocol is too small. By default, the key length must be greater
than or equal to 1024 bits to avoid vulnerabilities, even though it is strongly
recommended to use 2048 bits or larger for stronger security.
ERR_TLS_HANDSHAKE_TIMEOUT
#
TLS/SSL 握手超时。在这种情况下,服务器也必须中止连接。
¥A TLS/SSL handshake timed out. In this case, the server must also abort the connection.
ERR_TLS_INVALID_CONTEXT
#
上下文必须是 SecureContext
。
¥The context must be a SecureContext
.
ERR_TLS_INVALID_PROTOCOL_METHOD
#
指定的 secureProtocol
方法无效。它要么是未知的,要么是因为不安全而被禁用。
¥The specified secureProtocol
method is invalid. It is either unknown, or
disabled because it is insecure.
ERR_TLS_INVALID_PROTOCOL_VERSION
#
有效的 TLS 协议版本为 'TLSv1'
、'TLSv1.1'
或 'TLSv1.2'
。
¥Valid TLS protocol versions are 'TLSv1'
, 'TLSv1.1'
, or 'TLSv1.2'
.
ERR_TLS_INVALID_STATE
#
必须连接并安全建立 TLS 套接字。确保在继续之前触发 'secure' 事件。
¥The TLS socket must be connected and securely established. Ensure the 'secure' event is emitted before continuing.
ERR_TLS_PROTOCOL_VERSION_CONFLICT
#
尝试设置 TLS 协议 minVersion
或 maxVersion
与尝试显式设置 secureProtocol
冲突。使用一种或另一种机制。
¥Attempting to set a TLS protocol minVersion
or maxVersion
conflicts with an
attempt to set the secureProtocol
explicitly. Use one mechanism or the other.
ERR_TLS_PSK_SET_IDENTIY_HINT_FAILED
#
未能设置 PSK 身份提示。提示可能太长。
¥Failed to set PSK identity hint. Hint may be too long.
ERR_TLS_RENEGOTIATION_DISABLED
#
尝试在禁用重新协商的套接字实例上重新协商 TLS。
¥An attempt was made to renegotiate TLS on a socket instance with renegotiation disabled.
ERR_TLS_REQUIRED_SERVER_NAME
#
在使用 TLS 时,调用 server.addContext()
方法时没有在第一个参数中提供主机名。
¥While using TLS, the server.addContext()
method was called without providing
a host name in the first parameter.
ERR_TLS_SESSION_ATTACK
#
检测到过多的 TLS 重新协商,这是拒绝服务攻击的潜在载体。
¥An excessive amount of TLS renegotiations is detected, which is a potential vector for denial-of-service attacks.
ERR_TLS_SNI_FROM_SERVER
#
试图从 TLS 服务器端套接字触发服务器名称指示,它仅对客户端有效。
¥An attempt was made to issue Server Name Indication from a TLS server-side socket, which is only valid from a client.
ERR_TRACE_EVENTS_CATEGORY_REQUIRED
#
trace_events.createTracing()
方法至少需要一个跟踪事件类别。
¥The trace_events.createTracing()
method requires at least one trace event
category.
ERR_TRACE_EVENTS_UNAVAILABLE
#
无法加载 node:trace_events
模块,因为 Node.js 是使用 --without-v8-platform
标志编译的。
¥The node:trace_events
module could not be loaded because Node.js was compiled
with the --without-v8-platform
flag.
ERR_TRANSFORM_ALREADY_TRANSFORMING
#
Transform
流在它仍在转换时完成。
¥A Transform
stream finished while it was still transforming.
ERR_TRANSFORM_WITH_LENGTH_0
#
Transform
流完成,数据仍在写入缓冲区中。
¥A Transform
stream finished with data still in the write buffer.
ERR_TTY_INIT_FAILED
#
由于系统错误,终端的初始化失败。
¥The initialization of a TTY failed due to a system error.
ERR_UNAVAILABLE_DURING_EXIT
#
函数在 process.on('exit')
句柄中调用,不应在 process.on('exit')
句柄中调用。
¥Function was called within a process.on('exit')
handler that shouldn't be
called within process.on('exit')
handler.
ERR_UNCAUGHT_EXCEPTION_CAPTURE_ALREADY_SET
#
process.setUncaughtExceptionCaptureCallback()
被调用了两次,没有先将回调重置为 null
。
¥process.setUncaughtExceptionCaptureCallback()
was called twice,
without first resetting the callback to null
.
此错误旨在防止意外覆盖从另一个模块注册的回调。
¥This error is designed to prevent accidentally overwriting a callback registered from another module.
ERR_UNESCAPED_CHARACTERS
#
收到包含未转义字符的字符串。
¥A string that contained unescaped characters was received.
ERR_UNHANDLED_ERROR
#
发生未处理的错误(例如,当 EventEmitter
触发 'error'
事件但未注册 'error'
句柄时)。
¥An unhandled error occurred (for instance, when an 'error'
event is emitted
by an EventEmitter
but an 'error'
handler is not registered).
ERR_UNKNOWN_BUILTIN_MODULE
#
用于识别通常不应由用户代码触发的特定类型的内部 Node.js 错误。此错误的实例指向 Node.js 二进制文件本身的内部错误。
¥Used to identify a specific kind of internal Node.js error that should not typically be triggered by user code. Instances of this error point to an internal bug within the Node.js binary itself.
ERR_UNKNOWN_CREDENTIAL
#
传入了不存在的 Unix 群组或用户标识符。
¥A Unix group or user identifier that does not exist was passed.
ERR_UNKNOWN_ENCODING
#
传给 API 的编码选项无效或未知。
¥An invalid or unknown encoding option was passed to an API.
ERR_UNKNOWN_FILE_EXTENSION
#
¥Stability: 1 - Experimental
试图加载具有未知或不受支持的文件扩展名的模块。
¥An attempt was made to load a module with an unknown or unsupported file extension.
ERR_UNKNOWN_MODULE_FORMAT
#
¥Stability: 1 - Experimental
试图加载格式未知或不受支持的模块。
¥An attempt was made to load a module with an unknown or unsupported format.
ERR_UNKNOWN_SIGNAL
#
无效或未知的进程信号已传给需要有效信号的 API(例如 subprocess.kill()
)。
¥An invalid or unknown process signal was passed to an API expecting a valid
signal (such as subprocess.kill()
).
ERR_UNSUPPORTED_DIR_IMPORT
#
import
目录网址不受支持。取而代之的是 package.json
文件的 "exports"
字段中的 使用包的名称自引用包 和 定义自定义的子路径。
¥import
a directory URL is unsupported. Instead,
self-reference a package using its name and define a custom subpath in
the "exports"
field of the package.json
file.
import './'; // unsupported
import './index.js'; // supported
import 'package-name'; // supported
ERR_UNSUPPORTED_ESM_URL_SCHEME
#
不支持带有 file
和 data
以外的网址方案的 import
。
¥import
with URL schemes other than file
and data
is unsupported.
ERR_USE_AFTER_CLOSE
#
¥Stability: 1 - Experimental
试图使用已经关闭的东西。
¥An attempt was made to use something that was already closed.
ERR_VALID_PERFORMANCE_ENTRY_TYPE
#
在使用性能计时 API(perf_hooks
)时,找不到有效的性能条目类型。
¥While using the Performance Timing API (perf_hooks
), no valid performance
entry types are found.
ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING_FLAG
#
在没有 --experimental-vm-modules
的情况下调用了动态导入回调。
¥A dynamic import callback was invoked without --experimental-vm-modules
.
ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING
#
未指定动态导入回调。
¥A dynamic import callback was not specified.
ERR_VM_MODULE_ALREADY_LINKED
#
由于以下原因之一,尝试链接的模块不符合链接条件:
¥The module attempted to be linked is not eligible for linking, because of one of the following reasons:
-
已链接(
linkingStatus
为'linked'
)¥It has already been linked (
linkingStatus
is'linked'
) -
正在链接(
linkingStatus
为'linking'
)¥It is being linked (
linkingStatus
is'linking'
) -
此模块的链接失败(
linkingStatus
为'errored'
)¥Linking has failed for this module (
linkingStatus
is'errored'
)
ERR_VM_MODULE_CACHED_DATA_REJECTED
#
传给模块构造函数的 cachedData
选项无效。
¥The cachedData
option passed to a module constructor is invalid.
ERR_VM_MODULE_CANNOT_CREATE_CACHED_DATA
#
不能为已经评估过的模块创建缓存数据。
¥Cached data cannot be created for modules which have already been evaluated.
ERR_VM_MODULE_DIFFERENT_CONTEXT
#
从链接器函数返回的模块来自与父模块不同的上下文。链接的模块必须共享相同的上下文。
¥The module being returned from the linker function is from a different context than the parent module. Linked modules must share the same context.
ERR_VM_MODULE_LINK_FAILURE
#
由于失败,模块无法链接。
¥The module was unable to be linked due to a failure.
ERR_VM_MODULE_NOT_MODULE
#
链接 promise 的履行值不是 vm.Module
对象。
¥The fulfilled value of a linking promise is not a vm.Module
object.
ERR_VM_MODULE_STATUS
#
当前模块的状态不允许此操作。错误的具体含义取决于具体的函数。
¥The current module's status does not allow for this operation. The specific meaning of the error depends on the specific function.
ERR_WASI_ALREADY_STARTED
#
WASI 实例已经启动。
¥The WASI instance has already started.
ERR_WASI_NOT_STARTED
#
WASI 实例尚未启动。
¥The WASI instance has not been started.
ERR_WEBASSEMBLY_RESPONSE
#
已传给 WebAssembly.compileStreaming
或 WebAssembly.instantiateStreaming
的 Response
不是有效的 WebAssembly 响应。
¥The Response
that has been passed to WebAssembly.compileStreaming
or to
WebAssembly.instantiateStreaming
is not a valid WebAssembly response.
ERR_WORKER_INIT_FAILED
#
Worker
初始化失败。
¥The Worker
initialization failed.
ERR_WORKER_INVALID_EXEC_ARGV
#
传给 Worker
构造函数的 execArgv
选项包含无效标志。
¥The execArgv
option passed to the Worker
constructor contains
invalid flags.
ERR_WORKER_NOT_RUNNING
#
操作失败,因为 Worker
实例当前未运行。
¥An operation failed because the Worker
instance is not currently running.
ERR_WORKER_OUT_OF_MEMORY
#
Worker
实例因达到其内存限制而终止。
¥The Worker
instance terminated because it reached its memory limit.
ERR_WORKER_PATH
#
工作线程主脚本的路径既不是绝对路径也不是以 ./
或 ../
开头的相对路径。
¥The path for the main script of a worker is neither an absolute path
nor a relative path starting with ./
or ../
.
ERR_WORKER_UNSERIALIZABLE_ERROR
#
从工作线程序列化未捕获异常的所有尝试都失败了。
¥All attempts at serializing an uncaught exception from a worker thread failed.
ERR_WORKER_UNSUPPORTED_OPERATION
#
工作线程不支持请求的功能。
¥The requested functionality is not supported in worker threads.
ERR_ZLIB_INITIALIZATION_FAILED
#
由于配置不正确,创建 zlib
对象失败。
¥Creation of a zlib
object failed due to incorrect configuration.
HPE_HEADER_OVERFLOW
#
接收到了太多的 HTTP 标头数据。为了防止恶意或错误配置的客户端,如果接收到超过 8 KiB 的 HTTP 标头数据,则 HTTP 解析将中止,而不会创建请求或响应对象,并且将触发带有此代码的 Error
。
¥Too much HTTP header data was received. In order to protect against malicious or
malconfigured clients, if more than 8 KiB of HTTP header data is received then
HTTP parsing will abort without a request or response object being created, and
an Error
with this code will be emitted.
HPE_CHUNK_EXTENSIONS_OVERFLOW
#
块扩展收到的数据过多。为了防止恶意或配置错误的客户端,如果收到超过 16 KiB 的数据,则会触发带有此代码的 Error
。
¥Too much data was received for a chunk extensions. In order to protect against
malicious or malconfigured clients, if more than 16 KiB of data is received
then an Error
with this code will be emitted.
HPE_UNEXPECTED_CONTENT_LENGTH
#
服务器正在发送 Content-Length
标头和 Transfer-Encoding: chunked
。
¥Server is sending both a Content-Length
header and Transfer-Encoding: chunked
.
Transfer-Encoding: chunked
允许服务器为动态生成的内容维护 HTTP 持久连接。在这种情况下,无法使用 Content-Length
HTTP 标头。
¥Transfer-Encoding: chunked
allows the server to maintain an HTTP persistent
connection for dynamically generated content.
In this case, the Content-Length
HTTP header cannot be used.
使用 Content-Length
或 Transfer-Encoding: chunked
。
¥Use Content-Length
or Transfer-Encoding: chunked
.
MODULE_NOT_FOUND
#
当尝试 require()
操作或加载程序入口点时,CommonJS 模块加载器无法解析模块文件。
¥A module file could not be resolved by the CommonJS modules loader while
attempting a require()
operation or when loading the program entry point.
旧版 Node.js 错误代码#
¥Legacy Node.js error codes
¥Stability: 0 - Deprecated. These error codes are either inconsistent, or have been removed.
ERR_CANNOT_TRANSFER_OBJECT
#
传给 postMessage()
的值包含不支持传输的对象。
¥The value passed to postMessage()
contained an object that is not supported
for transferring.
ERR_CRYPTO_HASH_DIGEST_NO_UTF16
#
UTF-16 编码用于 hash.digest()
。虽然 hash.digest()
方法确实允许传入 encoding
参数,使该方法返回字符串而不是 Buffer
,但不支持 UTF-16 编码(例如 ucs
或 utf16le
)。
¥The UTF-16 encoding was used with hash.digest()
. While the
hash.digest()
method does allow an encoding
argument to be passed in,
causing the method to return a string rather than a Buffer
, the UTF-16
encoding (e.g. ucs
or utf16le
) is not supported.
ERR_HTTP2_FRAME_ERROR
#
在 HTTP/2 会话中发送单个帧失败时使用。
¥Used when a failure occurs sending an individual frame on the HTTP/2 session.
ERR_HTTP2_HEADERS_OBJECT
#
在需要 HTTP/2 标头对象时使用。
¥Used when an HTTP/2 Headers Object is expected.
ERR_HTTP2_HEADER_REQUIRED
#
当 HTTP/2 消息中缺少所需的标头时使用。
¥Used when a required header is missing in an HTTP/2 message.
ERR_HTTP2_INFO_HEADERS_AFTER_RESPOND
#
HTTP/2 信息标头只能在调用 Http2Stream.prototype.respond()
方法之前发送。
¥HTTP/2 informational headers must only be sent prior to calling the
Http2Stream.prototype.respond()
method.
ERR_HTTP2_STREAM_CLOSED
#
当在已关闭的 HTTP/2 流上执行操作时使用。
¥Used when an action has been performed on an HTTP/2 Stream that has already been closed.
ERR_HTTP_INVALID_CHAR
#
当在 HTTP 响应状态消息(原因短语)中发现无效字符时使用。
¥Used when an invalid character is found in an HTTP response status message (reason phrase).
ERR_INDEX_OUT_OF_RANGE
#
给定的索引超出了可接受的范围(例如负偏移量)。
¥A given index was out of the accepted range (e.g. negative offsets).
ERR_INVALID_OPT_VALUE
#
在选项对象中传入了无效或意外的值。
¥An invalid or unexpected value was passed in an options object.
ERR_INVALID_OPT_VALUE_ENCODING
#
传入了无效或未知的文件编码。
¥An invalid or unknown file encoding was passed.
ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST
#
此错误码在 Node.js v15.0.0 中被 ERR_MISSING_TRANSFERABLE_IN_TRANSFER_LIST
替换,因为它不再准确,因为现在还存在其他类型的可传输对象。
¥This error code was replaced by ERR_MISSING_TRANSFERABLE_IN_TRANSFER_LIST
in Node.js v15.0.0, because it is no longer accurate as other types of
transferable objects also exist now.
ERR_NAPI_CONS_PROTOTYPE_OBJECT
#
当 Constructor.prototype
不是对象时,由 Node-API
使用。
¥Used by the Node-API
when Constructor.prototype
is not an object.
ERR_NETWORK_IMPORT_BAD_RESPONSE
#
¥Stability: 1 - Experimental
当通过网络导入模块时收到响应但无效。
¥Response was received but was invalid when importing a module over the network.
ERR_NETWORK_IMPORT_DISALLOWED
#
¥Stability: 1 - Experimental
网络模块试图加载另一个不允许加载的模块。可能这个限制是出于安全原因。
¥A network module attempted to load another module that it is not allowed to load. Likely this restriction is for security reasons.
ERR_NO_LONGER_SUPPORTED
#
以不受支持的方式调用了 Node.js API,例如 Buffer.write(string, encoding, offset[, length])
。
¥A Node.js API was called in an unsupported manner, such as
Buffer.write(string, encoding, offset[, length])
.
ERR_OPERATION_FAILED
#
操作失败。这通常用于表示一般的异步操作失败。
¥An operation failed. This is typically used to signal the general failure of an asynchronous operation.
ERR_OUTOFMEMORY
#
通常用于识别操作导致内存不足的情况。
¥Used generically to identify that an operation caused an out of memory condition.
ERR_PARSE_HISTORY_DATA
#
node:repl
模块无法解析交互式解释器历史文件中的数据。
¥The node:repl
module was unable to parse data from the REPL history file.
ERR_SOCKET_CANNOT_SEND
#
无法在套接字上发送数据。
¥Data could not be sent on a socket.
ERR_STDERR_CLOSE
#
试图关闭 process.stderr
流。根据设计,Node.js 不允许用户代码关闭 stdout
或 stderr
流。
¥An attempt was made to close the process.stderr
stream. By design, Node.js
does not allow stdout
or stderr
streams to be closed by user code.
ERR_STDOUT_CLOSE
#
试图关闭 process.stdout
流。根据设计,Node.js 不允许用户代码关闭 stdout
或 stderr
流。
¥An attempt was made to close the process.stdout
stream. By design, Node.js
does not allow stdout
or stderr
streams to be closed by user code.
ERR_STREAM_READ_NOT_IMPLEMENTED
#
当尝试使用尚未实现 readable._read()
的可读流时使用。
¥Used when an attempt is made to use a readable stream that has not implemented
readable._read()
.
ERR_TLS_RENEGOTIATION_FAILED
#
当 TLS 重新协商请求以非特定方式失败时使用。
¥Used when a TLS renegotiation request has failed in a non-specific way.
ERR_TRANSFERRING_EXTERNALIZED_SHAREDARRAYBUFFER
#
在序列化过程中遇到内存不是由 JavaScript 引擎或 Node.js 管理的 SharedArrayBuffer
。这样的 SharedArrayBuffer
无法序列化。
¥A SharedArrayBuffer
whose memory is not managed by the JavaScript engine
or by Node.js was encountered during serialization. Such a SharedArrayBuffer
cannot be serialized.
这只有在原生插件在 "externalized" 模式下创建 SharedArrayBuffer
,或将现有的 SharedArrayBuffer
置于外部化模式时才会发生。
¥This can only happen when native addons create SharedArrayBuffer
s in
"externalized" mode, or put existing SharedArrayBuffer
into externalized mode.
ERR_UNKNOWN_STDIN_TYPE
#
尝试使用未知的 stdin
文件类型启动 Node.js 进程。此错误通常表明 Node.js 本身存在错误,尽管用户代码可能会触发它。
¥An attempt was made to launch a Node.js process with an unknown stdin
file
type. This error is usually an indication of a bug within Node.js itself,
although it is possible for user code to trigger it.
ERR_UNKNOWN_STREAM_TYPE
#
尝试使用未知的 stdout
或 stderr
文件类型启动 Node.js 进程。此错误通常表明 Node.js 本身存在错误,尽管用户代码可能会触发它。
¥An attempt was made to launch a Node.js process with an unknown stdout
or
stderr
file type. This error is usually an indication of a bug within Node.js
itself, although it is possible for user code to trigger it.
ERR_V8BREAKITERATOR
#
使用了 V8 BreakIterator
API,但未安装完整的 ICU 数据集。
¥The V8 BreakIterator
API was used but the full ICU data set is not installed.
ERR_VALUE_OUT_OF_RANGE
#
当给定值超出可接受范围时使用。
¥Used when a given value is out of the accepted range.
ERR_VM_MODULE_NOT_LINKED
#
模块必须在实例化前成功链接。
¥The module must be successfully linked before instantiation.
ERR_VM_MODULE_LINKING_ERRORED
#
链接器函数返回链接失败的模块。
¥The linker function returned a module for which linking has failed.
ERR_WORKER_UNSUPPORTED_EXTENSION
#
用于工作程序主脚本的路径名具有未知的文件扩展名。
¥The pathname used for the main script of a worker has an unknown file extension.
ERR_ZLIB_BINDING_CLOSED
#
在 zlib
对象已经关闭后尝试使用它时使用。
¥Used when an attempt is made to use a zlib
object after it has already been
closed.
ERR_CPU_USAGE
#
无法处理来自 process.cpuUsage
的原生调用。
¥The native call from process.cpuUsage
could not be processed.