Node.js v16.20.2 文档


错误#>

【Errors】

在 Node.js 中运行的应用通常会遇到四类错误:

【Applications running in Node.js will generally experience four categories of errors:】

  • 标准的 JavaScript 错误,例如 <EvalError><SyntaxError><RangeError><ReferenceError><TypeError><URIError>
  • 由于底层操作系统限制而触发的系统错误,例如尝试打开不存在的文件或尝试通过已关闭的套接字发送数据。
  • 由应用代码触发的用户指定错误。
  • AssertionError 是一种特殊的错误类别,当 Node.js 检测到绝不应该发生的逻辑违规时会触发。这类错误通常由 node:assert 模块引发。

由 Node.js 引发的所有 JavaScript 和系统错误都继承自标准 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 机制的任何使用都会引发一个异常,这个异常必须通过 try…catch 来处理,否则 Node.js 进程将立即退出。

【Any use of the JavaScript throw mechanism will raise an exception that must be handled using try…catch or the Node.js process will exit immediately.】

除了少数例外,同步 API(任何不接受 callback 函数的阻塞方法,例如 fs.readFileSync)将使用 throw 来报告错误。

【With few exceptions, Synchronous APIs (any blocking method that does not 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:】

  • 大多数接受 callback 函数的异步方法都会将一个 Error 对象作为该函数的第一个参数传入。如果第一个参数不是 null 并且是 Error 的实例,那么就发生了一个应当处理的错误。

    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' 事件。

    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 处理的异常。没有这些方法的完整列表;请参阅每个方法的文档,以确定所需的正确错误处理机制。

对于 基于流的基于事件触发器的 API,使用 'error' 事件机制是最常见的,它们本身代表了一系列随时间进行的异步操作(与可能成功或失败的单一操作相对)。

【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 进程报告未捕获的异常并崩溃,除非满足以下条件之一:适当使用了 domain 模块,或者已为 'uncaughtException' 事件注册了处理程序。

【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: The domain module is used appropriately or a handler has been registered for the 'uncaughtException' event.】

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-first callbacks】

Node.js 核心 API 提供的大多数异步方法遵循一种习惯用法模式,称为“错误优先回调”。在这种模式下,一个回调函数作为参数传递给方法。当操作完成或发生错误时,回调函数会被调用,并且将 Error 对象(如果有的话)作为第一个参数传入。如果没有发生错误,第一个参数将传入 null

【Most asynchronous methods exposed by the Node.js core API follow an idiomatic pattern referred to as an error-first callback. With this pattern, a callback function is passed to the method as an argument. When the operation either completes or an error is raised, the callback function is called with the Error object (if any) passed as the first argument. If no error was raised, the first argument will be passed as null.】

const fs = require('node:fs');

function errorFirstCallback(err, data) {
  if (err) {
    console.error('There was an error', err);
    return;
  }
  console.log(data);
}

fs.readFile('/some/file/that/does-not-exist', errorFirstCallback);
fs.readFile('/some/file/that/does-exist', errorFirstCallback); 

JavaScript 的 try…catch 机制不能用于拦截异步 API 产生的错误。初学者常犯的一个错误是尝试在错误优先的回调中使用 throw

【The JavaScript try…catch mechanism cannot be used to intercept errors generated by asynchronous APIs. A common mistake for beginners is to try to use throw inside an error-first callback:】

// THIS WILL NOT WORK:
const fs = require('node:fs');

try {
  fs.readFile('/some/file/that/does-not-exist', (err, data) => {
    // Mistaken assumption: throwing here...
    if (err) {
      throw err;
    }
  });
} catch (err) {
  // This will not catch the throw!
  console.error(err);
} 

这行不通,因为传给 fs.readFile() 的回调函数是异步调用的。在回调被调用时,外围代码,包括 try…catch 块,已经执行完毕。在回调内抛出错误在大多数情况下 可能会导致 Node.js 进程崩溃。如果启用了 域名,或者已经使用 process.on('uncaughtException') 注册了处理程序,这类错误是可以被拦截的。

【This will not work because the callback function passed to fs.readFile() is called asynchronously. By the time the callback has been called, the surrounding code, including the try…catch block, will have already exited. Throwing an error inside the callback can crash the Node.js process in most cases. If domains are enabled, or a handler has been registered with process.on('uncaughtException'), such errors can be intercepted.】

类: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 上创建一个 .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 MyError() {
  Error.captureStackTrace(this, MyError);
}

// Without passing MyError to captureStackTrace, the MyError
// frame would show up in the .stack property. By passing
// the constructor, we omit that frame, and retain all frames below it.
new MyError().stack; 

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 对象时,如果设置了 error.causeutil.inspect() 会递归地序列化它。

【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)。
  • plain-filename.js:line:column,如果该堆栈帧表示对 Node.js 内部的调用。
  • /absolute/path/to/file.js:line:column,如果该堆栈帧表示用户程序(使用 CommonJS 模块系统)或其依赖中的调用。
  • <transport-protocol>:///url/to/module/file.mjs:line:column,如果该堆栈帧表示用户程序(使用 ES 模块系统)或其依赖中的调用。

表示堆栈跟踪的字符串是在访问 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

表示断言失败。详情请参见 Class: assert.AssertionError

【Indicates the failure of an assertion. For details, see Class: assert.AssertionError.】

类:RangeError#>

【Class: RangeError

表示提供的参数不在函数可接受值的集合或范围内;无论是数值范围,还是超出了给定函数参数的选项集合。

【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

表示正在尝试访问一个未定义的变量。这类错误通常表示代码中有拼写错误,或者程序本身存在其他问题。

【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

表示程序不是有效的 JavaScript。这些错误可能仅作为代码评估的结果被产生和传播。代码评估可能由于使用 evalFunctionrequire虚拟机 而发生。这些错误几乎总是表明程序出现了问题。

【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 实例在创建它们的上下文中是无法恢复的——它们只能被其他上下文捕获。

类:SystemError#>

【Class: SystemError

当 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> 如果存在,表示网络连接失败的地址
  • code <string> 字符串形式的错误代码
  • dest <string> 如果存在,报告文件系统错误时的文件路径目标
  • errno <number> 系统提供的错误编号
  • info <Object> 如果存在,关于错误情况的额外信息
  • message <string> 系统提供的可读错误描述
  • path <string> 如果存在,报告文件系统错误时的文件路径
  • port <number> 如果存在,网络连接不可用的端口
  • syscall <string> 引发错误的系统调用名称

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.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(权限被拒绝):尝试以文件访问权限不允许的方式访问文件。

  • EADDRINUSE(地址已被使用):尝试将服务器(nethttphttps)绑定到本地地址时失败,因为本地系统上的另一个服务器已占用该地址。

  • ECONNREFUSED(连接被拒绝):无法建立连接,因为目标机器主动拒绝了连接。这通常是由于尝试连接到目标主机上处于非活动状态的服务导致的。

  • ECONNRESET(连接被对方重置):连接被对方强制关闭。通常是由于远程套接字的连接因超时或重启而丢失导致的。通常在 httpnet 模块中会遇到。

  • EEXIST(文件已存在):操作的目标文件已存在,而该操作要求目标文件不存在。

  • EISDIR(是一个目录):操作本应针对文件,但给定的路径名是一个目录。

  • EMFILE(系统中打开的文件过多):系统中可允许的 文件描述符 数量已达到上限,在至少关闭一个文件之前,无法处理更多文件描述符的请求。当同时并行打开许多文件时会遇到此问题,尤其是在文件描述符限制较低的系统(特别是 macOS)中。若要解决限制过低的问题,请在将运行 Node.js 进程的同一 shell 中执行 ulimit -n 2048

  • ENOENT(没有这样的文件或目录):通常由 fs 操作引发,用于表示指定路径的某个组件不存在。无法通过给定路径找到任何实体(文件或目录)。

  • ENOTDIR(不是目录):给定路径名的某个组件存在,但并非预期的目录。通常由 fs.readdir 引发。

  • ENOTEMPTY(目录非空):操作的目标是包含条目的目录,而该操作通常需要一个空目录,通常是 fs.unlink

  • ENOTFOUND(DNS 查询失败):表示 EAI_NODATAEAI_NONAME 的 DNS 失败。这不是标准的 POSIX 错误。

  • EPERM(操作不允许):尝试执行需要提升权限的操作。

  • EPIPE(管道断裂):对没有进程读取数据的管道、套接字或 FIFO 进行写操作。通常在 nethttp 层遇到,表明写入的流的远端已被关闭。

  • ETIMEDOUT(操作超时):连接或发送请求失败,因为连接的另一方在一段时间后没有正确响应。通常由 httpnet 遇到。通常表示 socket.end() 没有被正确调用。

类:TypeError#>

【Class: TypeError

表示提供的参数类型不允许。例如,将一个函数传递给期望字符串的参数就会导致 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】

cryptotls 中产生的错误属于 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 AbortSignals typically do not raise an error with this code.】

此代码未使用 Node.js 错误中常用的 ERR_* 约定,以便兼容 Web 平台的 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 尝试访问 政策 清单限制的资源时会触发。例如,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#>

尝试从 addon 或嵌入器代码创建一个 Node.js Buffer 实例时,所处的 JS 引擎上下文并未关联到 Node.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 通常可以在所有接受 Buffer 的 Node.js 核心 API 中使用;它们在所有上下文中都可用。

【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. Uint8Arrays are generally accepted in all Node.js core APIs where Buffers 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#>

当主进程尝试从子进程的 STDERR/STDOUT 读取数据时使用,而数据的长度超过了 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 流的情况下被实例化,或者 Consolestdoutstderr 流不可写。

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 的 vm 上下文尚未初始化。这可能发生在创建上下文时出现错误(并被捕获)的情况,例如,当分配失败或创建上下文时达到最大调用堆栈大小。

【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 版本不支持该引擎。

【A client certificate engine was requested that is not supported by the version of OpenSSL being used.】

ERR_CRYPTO_ECDH_INVALID_FORMAT#>

crypto.ECDH() 类的 getPublicKey() 方法传递了 format 参数的无效值。

【An invalid value for the format argument was passed to the crypto.ECDH() class getPublicKey() method.】

ERR_CRYPTO_ECDH_INVALID_PUBLIC_KEY#>

crypto.ECDH() 类的 computeSecret() 方法传递了 key 参数的无效值。这意味着公钥位于椭圆曲线之外。

【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() 方法最多只能调用一次。

ERR_CRYPTO_HASH_UPDATE_FAILED#>

hash.update() 由于某种原因失败。这种情况应该很少发生,甚至几乎不会发生。

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#>

该密钥的椭圆曲线未在 JSON 网络密钥椭圆曲线注册表 中注册使用。

【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() 被调用时,其 BufferTypedArrayDataView 参数长度不一致。

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#>

调试器发生错误。

【An error occurred with the debugger.】

ERR_DEBUGGER_STARTUP_ERROR#>

调试器 等待所需的主机/端口可用时超时。

【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 上尝试了同步读取或关闭调用,但该 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 设置 DNS 服务器失败。

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 模块在之前已经被加载。

堆栈跟踪已扩展,以包括 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()无法被调用,因为它之前已经被调用过。

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 输入一起使用。

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(),并且 forceerrorOnExist 被设置为 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() 时,srcdest 指向了无效的路径。

【When using fs.cp(), src or dest pointed to an invalid path.】

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_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#>

Http2Session 收到来自连接对端的 GOAWAY 帧后,可能无法打开新的 HTTP/2 流。

【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 信息性状态码。信息性状态码必须是介于 100199(包含)之间的整数。

【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 的 BufferUint8Array 实例的长度必须是六的倍数。

【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 发送非普通文件的内容,但提供了 offsetlength 选项。

【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.Sockettls.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#>

尝试使用已关闭的 Http2Sessionsocket 属性。

【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 状态码。状态码必须是介于 100599(含)之间的整数。

【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.sendTrailers() 方法在 Http2Stream 对象触发 'wantTrailers' 事件之前无法调用。只有在为 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() 接收到的 URL 使用了除 http:https: 之外的其他协议。

ERR_ILLEGAL_CONSTRUCTOR#>

尝试使用非公共构造函数构造对象。

【An attempt was made to construct an object using a non-public constructor.】

ERR_IMPORT_ASSERTION_TYPE_FAILED#>

导入断言失败,阻止导入指定的模块。

【An import assertion has failed, preventing the specified module to be imported.】

ERR_IMPORT_ASSERTION_TYPE_MISSING#>

缺少导入断言,阻止导入指定的模块。

【An import assertion is missing, preventing the specified module to be imported.】

ERR_IMPORT_ASSERTION_TYPE_UNSUPPORTED#>

此版本的 Node.js 不支持导入断言。

【An import assertion 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#>

稳定性: 1 - 实验性

--input-type 标志被用于尝试执行一个文件。该标志只能与通过 --eval--printSTDIN 输入时使用。

【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 模块时,尝试在连接之前使用 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 提交一个问题。

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 传递了无效的 asyncIdtriggerAsyncId。ID 小于 -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_CALLBACK#>

回调函数是必需的,但未提供给 Node.js API。

【A callback function was required but was not been provided to a Node.js API.】

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#>

一个使用 Node.js 的 API 消费 file: URL(例如 fs 模块中的某些函数)时,遇到了具有不兼容主机的文件 URL。此情况只会发生在类 Unix 系统上,因为这些系统只支持 localhost 或空主机。

【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#>

一个使用 Node.js 的 API,它可以处理 file: URL(例如 fs 模块中的某些函数),遇到了路径不兼容的文件 URL。判断路径是否可用的具体语义取决于平台。

【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 通信通道向子进程发送不受支持的“句柄”。更多信息请参见 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_MODULE#>

尝试加载不存在或无效的模块。

【An attempt was made to load a module that does not exist or was otherwise not valid.】

ERR_INVALID_MODULE_SPECIFIER#>

导入的模块字符串是无效的 URL、包名或包子路径指定符。

【The imported module string is an invalid URL, package name, or package subpath specifier.】

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#>

http.request() 传递了无效的 options.protocol

【An invalid options.protocol was passed to http.request().】

ERR_INVALID_REPL_EVAL_CONFIG#>

REPL 配置中同时设置了 breakEvalOnSiginteval 选项,这是不被支持的。

【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#>

一个 BufferTypedArrayDataViewstring 被作为 stdio 输入提供给异步 fork。有关更多信息,请参阅 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#>

调用 Node.js API 函数时使用了不兼容的 this 值。

【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#>

传递给 WHATWGURL 构造函数 的 URL 无效,需要解析。抛出的错误对象通常有一个额外的属性 'input',其中包含解析失败的 URL。

【An invalid URL was passed to the WHATWG URL constructor 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#>

尝试使用不兼容方案(协议)的 URL 来实现特定目的。它仅在 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#>

尝试断开一个已经断开的 IPC 通信通道。有关更多信息,请参见 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#>

尝试使用多个 IPC 通信通道创建子 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 进程打开 IPC 通信通道。更多信息请参阅 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#>

尝试加载资源时,该资源与策略清单中定义的完整性不符。有关更多信息,请参阅政策清单的文档。

【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#>

尝试加载一个资源,但该资源并未在尝试加载它的位置列为依赖。有关更多信息,请参阅 政策 清单的文档。

【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#>

尝试加载策略清单时发生错误,但清单中某个资源有多个条目且彼此不匹配。请更新清单条目使其匹配,以解决此错误。有关 政策 清单的更多信息,请参阅文档。

【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#>

策略清单资源的某个字段值无效。请更新清单条目以匹配此值,以解决此错误。有关 政策 清单的更多信息,请参阅文档。

【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#>

策略清单资源的某个依赖映射值无效。请更新清单条目以匹配,以解决此错误。有关更多信息,请参阅 政策 清单的文档。

【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#>

尝试加载策略清单,但无法解析该清单。有关 政策 清单的详细信息,请参阅文档。

【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”行为具有未知值。有关 政策 清单的更多信息,请参阅文档。

【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#>

发布到 MessagePort 的消息无法在目标 虚拟机 Context 中反序列化。目前,并非所有 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 平台不支持创建 Workers。这是由于嵌入器对 Workers 缺乏支持引起的。尤其是,使用标准构建的 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.】

在 Node.js v15.0.0 之前的版本中,这里使用的错误代码是 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 超出了 DataView 的范围,或者 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#>

尝试使用需要 重症监护室 的功能,但 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" 字段未导出所请求的子路径。由于导出是封装的,未导出的私有内部模块不能通过包解析进行导入,除非使用绝对 URL。

【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#>

util.parseArgs() 抛出,当提供了位置参数且 allowPositionals 设置为 false 时。

【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.getPrototypeOfObject.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#>

稳定性: 1 - 实验性

尝试 require() 一个 ES 模块

【An attempt was made to require() an ES Module.】

ERR_SCRIPT_EXECUTION_INTERRUPTED#>

脚本执行被 SIGINT 中断(例如,按下了 Ctrl+C )。

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() 中,为 recvBufferSizesendBufferSize 选项传递了无效(负数)的大小。

【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#>

一个期望接收套接字类型(udp4udp6)的 API 函数收到了无效的值。

【An API function expecting a socket type (udp4 or udp6) received an invalid value.】

ERR_SOCKET_BUFFER_SIZE#>

在使用 dgram.createSocket() 时,接收或发送缓冲区的大小无法确定。

【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_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#>

如果在 Socket 上设置了字符串解码器,或者解码器处于 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_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_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 协议的 minVersionmaxVersion 会与明确设置 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 的套接字实例上重新协商 TLS。

【An attempt was made to renegotiate TLS on a socket instance with TLS 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 服务器端套接字发送服务器名称指示(SNI),这仅对客户端有效。

【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

此错误旨在防止意外覆盖从其他模块注册的回调。

【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#>

稳定性: 1 - 实验性

尝试加载具有未知或不支持的文件扩展名的模块。

【An attempt was made to load a module with an unknown or unsupported file extension.】

ERR_UNKNOWN_MODULE_FORMAT#>

稳定性: 1 - 实验性

试图加载格式未知或不受支持的模块。

【An attempt was made to load a module with an unknown or unsupported format.】

ERR_UNKNOWN_SIGNAL#>

向期望有效信号(例如 subprocess.kill())的 API 传递了无效或未知的进程信号。

【An invalid or unknown process signal was passed to an API expecting a valid signal (such as subprocess.kill()).】

ERR_UNSUPPORTED_DIR_IMPORT#>

import 目录 URL 不被支持。相反,请在 package.json 文件的 "exports" 字段中使用 使用包名进行自我引用定义自定义子路径

import './'; // unsupported
import './index.js'; // supported
import 'package-name'; // supported 

ERR_UNSUPPORTED_ESM_URL_SCHEME#>

不支持使用除 filedata 之外的 URL 方案的 import

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#>

未指定动态导入回调。

【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'
  • 它正在关联中(linkingStatus'linking'
  • 此模块关联失败(linkingStatus'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#>

链接承诺的已实现值不是 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_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#>

worker 的主脚本的路径既不是绝对路径,也不是以 ./../ 开头的相对路径。

【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_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 头。

使用 Content-LengthTransfer-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】

稳定性: 0 - 已弃用。这些错误代码要么不一致,要么已被移除。

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 编码(例如 ucsutf16le)是不被支持的。

【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#>

稳定性: 1 - 实验性

当通过网络导入模块时收到响应但无效。

【Response was received but was invalid when importing a module over the network.】

ERR_NETWORK_IMPORT_DISALLOWED#>

稳定性: 1 - 实验性

网络模块试图加载另一个它不被允许加载的模块。此限制很可能是出于安全原因。

【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 模块无法解析 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 不允许用户代码关闭 stdoutstderr 流。

【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 不允许用户代码关闭 stdoutstderr 流。

【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.】

这只能发生在本地插件以“外部化”模式创建 SharedArrayBuffer 时,或者将已有的 SharedArrayBuffer 置于外部化模式时。

【This can only happen when native addons create SharedArrayBuffers 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#>

尝试启动一个具有未知 stdoutstderr 文件类型的 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#>

用于 worker 主脚本的路径名具有未知的文件扩展名。

【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.】

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