- assert 断言
- async_hooks 异步钩子
- async_hooks/context 异步上下文
- buffer 缓冲区
- C++插件
- C/C++插件(使用 Node-API)
- C++嵌入器
- child_process 子进程
- cluster 集群
- CLI 命令行
- console 控制台
- crypto 加密
- crypto/webcrypto 网络加密
- debugger 调试器
- deprecation 弃用
- dgram 数据报
- diagnostics_channel 诊断通道
- dns 域名服务器
- domain 域
- env 环境变量
- Error 错误
- events 事件触发器
- fs 文件系统
- global 全局变量
- http 超文本传输协议
- http2 超文本传输协议 2.0
- https 安全超文本传输协议
- inspector 检查器
- Intl 国际化
- module 模块
- module/cjs CommonJS 模块
- module/esm ECMAScript 模块
- module/package 包模块
- module/typescript TS 模块
- net 网络
- os 操作系统
- path 路径
- perf_hooks 性能钩子
- permission 权限
- process 进程
- punycode 域名代码
- querystring 查询字符串
- readline 逐行读取
- repl 交互式解释器
- report 诊断报告
- sea 单个可执行应用程序
- sqlite 轻型数据库
- stream 流
- stream/web 网络流
- string_decoder 字符串解码器
- test 测试
- timers 定时器
- tls 安全传输层
- trace_events 跟踪事件
- tty 终端
- url 网址
- util 实用工具
- v8 引擎
- vm 虚拟机
- wasi 网络汇编系统接口
- worker_threads 工作线程
- zlib 压缩
Node.js v25.3.0 文档
- Node.js v25.3.0
-
目录
- 操作系统
os.EOLos.availableParallelism()os.arch()os.constantsos.cpus()os.devNullos.endianness()os.freemem()os.getPriority([pid])os.homedir()os.hostname()os.loadavg()os.machine()os.networkInterfaces()os.platform()os.release()os.setPriority([pid, ]priority)os.tmpdir()os.totalmem()os.type()os.uptime()os.userInfo([options])os.version()- 操作系统常量
- 操作系统
-
导航
- assert 断言
- async_hooks 异步钩子
- async_hooks/context 异步上下文
- buffer 缓冲区
- C++插件
- C/C++插件(使用 Node-API)
- C++嵌入器
- child_process 子进程
- cluster 集群
- CLI 命令行
- console 控制台
- crypto 加密
- crypto/webcrypto 网络加密
- debugger 调试器
- deprecation 弃用
- dgram 数据报
- diagnostics_channel 诊断通道
- dns 域名服务器
- domain 域
- env 环境变量
- Error 错误
- events 事件触发器
- fs 文件系统
- global 全局变量
- http 超文本传输协议
- http2 超文本传输协议 2.0
- https 安全超文本传输协议
- inspector 检查器
- Intl 国际化
- module 模块
- module/cjs CommonJS 模块
- module/esm ECMAScript 模块
- module/package 包模块
- module/typescript TS 模块
- net 网络
- os 操作系统
- path 路径
- perf_hooks 性能钩子
- permission 权限
- process 进程
- punycode 域名代码
- querystring 查询字符串
- readline 逐行读取
- repl 交互式解释器
- report 诊断报告
- sea 单个可执行应用程序
- sqlite 轻型数据库
- stream 流
- stream/web 网络流
- string_decoder 字符串解码器
- test 测试
- timers 定时器
- tls 安全传输层
- trace_events 跟踪事件
- tty 终端
- url 网址
- util 实用工具
- v8 引擎
- vm 虚拟机
- wasi 网络汇编系统接口
- worker_threads 工作线程
- zlib 压缩
- 其他版本
操作系统#>
【OS】
源代码: lib/os.js
node:os 模块提供与操作系统相关的实用方法和属性。可以通过以下方式访问:
【The node:os module provides operating system-related utility methods and
properties. It can be accessed using:】
import os from 'node:os';const os = require('node:os');
os.EOL#>
- 类型:<string>
操作系统特定的行尾标记。
【The operating system-specific end-of-line marker.】
在 POSIX 上在 Windows 上
os.availableParallelism()#>
- 返回:<integer>
返回程序应使用的默认并行度的估计值。 始终返回大于零的值。
【Returns an estimate of the default amount of parallelism a program should use. Always returns a value greater than zero.】
这个函数是关于 libuv 的 uv_available_parallelism() 的一个小封装。
【This function is a small wrapper about libuv's uv_available_parallelism().】
os.arch()#>
- 返回:<string>
返回用于编译 Node.js 二进制文件的操作系统 CPU 架构。可能的值有 'arm'、'arm64'、'ia32'、'loong64'、'mips'、'mipsel'、'ppc64'、'riscv64'、's390x' 和 'x64'。
【Returns the operating system CPU architecture for which the Node.js binary was
compiled. Possible values are 'arm', 'arm64', 'ia32', 'loong64',
'mips', 'mipsel', 'ppc64', 'riscv64', 's390x', and 'x64'.】
返回值等同于 process.arch。
【The return value is equivalent to process.arch.】
os.constants#>
- 类型: <Object>
包含常用的操作系统特定常量,如错误代码、进程信号等。定义的具体常量在操作系统常量中描述。
【Contains commonly used operating system-specific constants for error codes, process signals, and so on. The specific constants defined are described in OS constants.】
os.cpus()#>
- 返回:对象[]
返回一个包含每个逻辑 CPU 核心信息的对象数组。如果无法获取 CPU 信息,例如 /proc 文件系统不可用,则数组将为空。
【Returns an array of objects containing information about each logical CPU core.
The array will be empty if no CPU information is available, such as if the
/proc file system is unavailable.】
每个对象上包含的属性包括:
【The properties included on each object include:】
[
{
model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
speed: 2926,
times: {
user: 252020,
nice: 0,
sys: 30340,
idle: 1070356870,
irq: 0,
},
},
{
model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
speed: 2926,
times: {
user: 306960,
nice: 0,
sys: 26980,
idle: 1071569080,
irq: 0,
},
},
{
model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
speed: 2926,
times: {
user: 248450,
nice: 0,
sys: 21750,
idle: 1070919370,
irq: 0,
},
},
{
model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
speed: 2926,
times: {
user: 256880,
nice: 0,
sys: 19430,
idle: 1070905480,
irq: 20,
},
},
]
nice 值仅适用于 POSIX。在 Windows 上,所有处理器的 nice 值始终为 0。
不应使用 os.cpus().length 来计算应用可用的并行数量。应使用 os.availableParallelism() 来实现此目的。
os.devNull#>
- 类型:<string>
空设备的特定于平台的文件路径。
【The platform-specific file path of the null device.】
\. ul在 Windows 上- POSIX 系统上的
/dev/null
os.endianness()#>
- 返回:<string>
返回一个字符串,用于标识编译 Node.js 二进制文件的 CPU 的字节序。
【Returns a string identifying the endianness of the CPU for which the Node.js binary was compiled.】
可能的值为 'BE' 表示大端,'LE' 表示小端。
【Possible values are 'BE' for big endian and 'LE' for little endian.】
os.freemem()#>
- 返回:<integer>
以整数形式返回空闲的系统内存量(以字节为单位)。
【Returns the amount of free system memory in bytes as an integer.】
os.getPriority([pid])#>
返回由 pid 指定的进程的调度优先级。如果未提供 pid 或 pid 为 0,则返回当前进程的优先级。
【Returns the scheduling priority for the process specified by pid. If pid is
not provided or is 0, the priority of the current process is returned.】
os.homedir()#>
- 返回:<string>
返回当前用户的主目录的字符串路径。
【Returns the string path of the current user's home directory.】
在 POSIX 系统上,如果定义了 $HOME 环境变量,则使用它。否则,它使用 有效的UID 查找用户的主目录。
【On POSIX, it uses the $HOME environment variable if defined. Otherwise it
uses the effective UID to look up the user's home directory.】
在 Windows 上,如果定义了 USERPROFILE 环境变量,它将使用该变量。否则,它将使用当前用户的配置文件目录路径。
【On Windows, it uses the USERPROFILE environment variable if defined.
Otherwise it uses the path to the profile directory of the current user.】
os.hostname()#>
- 返回:<string>
以字符串形式返回操作系统的主机名。
【Returns the host name of the operating system as a string.】
os.loadavg()#>
- 返回次数:编号[]
返回包含 1、5 和 15 分钟平均负载的数组。
【Returns an array containing the 1, 5, and 15 minute load averages.】
负载平均值是操作系统计算的系统活动的度量,并以小数形式表示。
【The load average is a measure of system activity calculated by the operating system and expressed as a fractional number.】
负载平均值是 Unix 特有的概念。在 Windows 上,返回值始终是 [0, 0, 0]。
【The load average is a Unix-specific concept. On Windows, the return value is
always [0, 0, 0].】
os.machine()#>
- 返回:<string>
返回机器类型的字符串,例如 arm、arm64、aarch64、mips、mips64、ppc64、ppc64le、s390x、i386、i686、x86_64。
【Returns the machine type as a string, such as arm, arm64, aarch64,
mips, mips64, ppc64, ppc64le, s390x, i386, i686, x86_64.】
在 POSIX 系统上,机器类型是通过调用 uname(3) 来确定的。在 Windows 上,使用 RtlGetVersion(),如果不可用,则使用 GetVersionExW()。更多信息请参见
https://en.wikipedia.org/wiki/Uname#Examples 。
os.networkInterfaces()#>
- 返回:<Object>
返回一个包含已分配网络地址的网络接口的对象。
【Returns an object containing network interfaces that have been assigned a network address.】
返回对象上的每个键都标识一个网络接口。相关的值是一个对象数组,每个对象描述一个分配的网络地址。
【Each key on the returned object identifies a network interface. The associated value is an array of objects that each describe an assigned network address.】
分配的网络地址对象上可用的属性包括:
【The properties available on the assigned network address object include:】
address<string> 分配的 IPv4 或 IPv6 地址netmask<string> IPv4 或 IPv6 网络掩码family<string> 可以是IPv4或IPv6mac<string> 网络接口的 MAC 地址internal<boolean> 如果网络接口是回环或类似的不可远程访问的接口,则为true;否则为falsescopeid<number> 数值型 IPv6 范围 ID(仅在family为IPv6时指定)cidr<string> 使用 CIDR 表示法的分配的 IPv4 或 IPv6 地址及路由前缀。如果netmask无效,则此属性设置为null。
{
lo: [
{
address: '127.0.0.1',
netmask: '255.0.0.0',
family: 'IPv4',
mac: '00:00:00:00:00:00',
internal: true,
cidr: '127.0.0.1/8'
},
{
address: '::1',
netmask: 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff',
family: 'IPv6',
mac: '00:00:00:00:00:00',
scopeid: 0,
internal: true,
cidr: '::1/128'
}
],
eth0: [
{
address: '192.168.1.108',
netmask: '255.255.255.0',
family: 'IPv4',
mac: '01:02:03:0a:0b:0c',
internal: false,
cidr: '192.168.1.108/24'
},
{
address: 'fe80::a00:27ff:fe4e:66a1',
netmask: 'ffff:ffff:ffff:ffff::',
family: 'IPv6',
mac: '01:02:03:0a:0b:0c',
scopeid: 1,
internal: false,
cidr: 'fe80::a00:27ff:fe4e:66a1/64'
}
]
}
os.platform()#>
- 返回:<string>
返回一个字符串,标识 Node.js 二进制文件编译时所针对的操作系统平台。该值在编译时设置。可能的值包括 'aix'、'darwin'、'freebsd'、'linux'、'openbsd'、'sunos' 和 'win32'。
【Returns a string identifying the operating system platform for which
the Node.js binary was compiled. The value is set at compile time.
Possible values are 'aix', 'darwin', 'freebsd','linux',
'openbsd', 'sunos', and 'win32'.】
返回值等同于 process.platform。
【The return value is equivalent to process.platform.】
如果 Node.js 构建在 Android 操作系统上,也可能返回值 'android'。Android 支持处于试验阶段。
【The value 'android' may also be returned if Node.js is built on the Android
operating system. Android support is experimental.】
os.release()#>
- 返回:<string>
以字符串形式返回操作系统。
【Returns the operating system as a string.】
在 POSIX 系统上,操作系统版本是通过调用 uname(3) 来确定的。在 Windows 上,则使用 GetVersionExW()。更多信息请参见
https://en.wikipedia.org/wiki/Uname#Examples 。
os.setPriority([pid, ]priority)#>
尝试为指定 pid 的进程设置调度优先级。如果未提供 pid 或 pid 为 0,则使用当前进程的进程 ID。
【Attempts to set the scheduling priority for the process specified by pid. If
pid is not provided or is 0, the process ID of the current process is used.】
priority 输入必须是介于 -20(高优先级)和 19(低优先级)之间的整数。由于 Unix 优先级级别与 Windows 优先级类之间存在差异,priority 会映射到 os.constants.priority 中的六个优先级常量之一。在检索进程优先级时,这种范围映射可能导致 Windows 上的返回值略有不同。为避免混淆,请将 priority 设置为其中一个优先级常量。
【The priority input must be an integer between -20 (high priority) and 19
(low priority). Due to differences between Unix priority levels and Windows
priority classes, priority is mapped to one of six priority constants in
os.constants.priority. When retrieving a process priority level, this range
mapping may cause the return value to be slightly different on Windows. To avoid
confusion, set priority to one of the priority constants.】
在 Windows 上,将优先级设置为 PRIORITY_HIGHEST 需要提升的用户权限。否则,设置的优先级将会被悄悄降低到 PRIORITY_HIGH。
【On Windows, setting priority to PRIORITY_HIGHEST requires elevated user
privileges. Otherwise the set priority will be silently reduced to
PRIORITY_HIGH.】
os.tmpdir()#>
- 返回:<string>
以字符串形式返回操作系统的默认临时文件目录。
【Returns the operating system's default directory for temporary files as a string.】
在 Windows 上,结果可以通过 TEMP 和 TMP 环境变量来覆盖,其中 TEMP 优先于 TMP。如果两者都未设置,则默认为 %SystemRoot%\temp 或 %windir%\temp。
【On Windows, the result can be overridden by TEMP and TMP environment variables, and
TEMP takes precedence over TMP. If neither is set, it defaults to %SystemRoot%\temp
or %windir%\temp.】
在非 Windows 平台上,将按描述的顺序检查 TMPDIR、TMP 和 TEMP 环境变量,以覆盖此方法的结果。如果它们都未设置,则默认使用 /tmp。
【On non-Windows platforms, TMPDIR, TMP and TEMP environment variables will be checked
to override the result of this method, in the described order. If none of them is set, it
defaults to /tmp.】
一些操作系统发行版会默认配置 TMPDIR(非 Windows)或 TEMP 和 TMP(Windows),而无需系统管理员进行额外配置。os.tmpdir() 的结果通常反映系统偏好,除非用户明确覆盖了该设置。
【Some operating system distributions would either configure TMPDIR (non-Windows) or
TEMP and TMP (Windows) by default without additional configurations by the system
administrators. The result of os.tmpdir() typically reflects the system preference
unless it's explicitly overridden by the users.】
os.totalmem()#>
- 返回:<integer>
以整数形式返回系统内存总量(以字节为单位)。
【Returns the total amount of system memory in bytes as an integer.】
os.type()#>
- 返回:<string>
返回 uname(3) 提供的操作系统名称。例如,在 Linux 上返回 'Linux',在 macOS 上返回 'Darwin',在 Windows 上返回 'Windows_NT'。
【Returns the operating system name as returned by uname(3). For example, it
returns 'Linux' on Linux, 'Darwin' on macOS, and 'Windows_NT' on Windows.】
有关在各种操作系统上运行 uname(3) 的输出的更多信息,请参见 https://en.wikipedia.org/wiki/Uname#Examples 。
os.uptime()#>
- 返回:<integer>
以秒为单位返回系统正常运行时间。
【Returns the system uptime in number of seconds.】
os.userInfo([options])#>
options<Object>encoding<string> 用于解释生成字符串的字符编码。 如果encoding设置为'buffer',username、shell和homedir的值将是Buffer实例。默认值:'utf8'。
- 返回:<Object>
返回有关当前有效用户的信息。在 POSIX 平台上,这通常是密码文件的一个子集。返回的对象包含 username、uid、gid、shell 和 homedir。在 Windows 上,uid 和 gid 字段为 -1,而 shell 为 null。
【Returns information about the currently effective user. On POSIX platforms,
this is typically a subset of the password file. The returned object includes
the username, uid, gid, shell, and homedir. On Windows, the uid and
gid fields are -1, and shell is null.】
os.userInfo() 返回的 homedir 值由操作系统提供。这与 os.homedir() 的结果不同,后者会先查询环境变量来获取主目录,然后才回退到操作系统的响应。
【The value of homedir returned by os.userInfo() is provided by the operating
system. This differs from the result of os.homedir(), which queries
environment variables for the home directory before falling back to the
operating system response.】
如果用户没有 username 或 homedir,则抛出 SystemError。
【Throws a SystemError if a user has no username or homedir.】
os.version()#>
- 返回:<string>
返回标识内核版本的字符串。
【Returns a string identifying the kernel version.】
在 POSIX 系统上,操作系统版本通过调用 uname(3) 来确定。在 Windows 上,使用 RtlGetVersion(),如果不可用,则使用 GetVersionExW()。更多信息请参见
https://en.wikipedia.org/wiki/Uname#Examples 。
操作系统常量#>
【OS constants】
os.constants 导出了以下常量。
【The following constants are exported by os.constants.】
并非所有常量都适用于每个操作系统。
【Not all constants will be available on every operating system.】
信号常量#>
【Signal constants】
os.constants.signals 导出了以下信号常量。
【The following signal constants are exported by os.constants.signals.】
| Constant | Description |
|---|---|
SIGHUP |
Sent to indicate when a controlling terminal is closed or a parent process exits. |
SIGINT |
Sent to indicate when a user wishes to interrupt a process (Ctrl+C). |
SIGQUIT |
Sent to indicate when a user wishes to terminate a process and perform a core dump. |
SIGILL |
Sent to a process to notify that it has attempted to perform an illegal, malformed, unknown, or privileged instruction. |
SIGTRAP |
Sent to a process when an exception has occurred. |
SIGABRT |
Sent to a process to request that it abort. |
SIGIOT |
Synonym for SIGABRT |
SIGBUS |
Sent to a process to notify that it has caused a bus error. |
SIGFPE |
Sent to a process to notify that it has performed an illegal arithmetic operation. |
SIGKILL |
Sent to a process to terminate it immediately. |
SIGUSR1 SIGUSR2 |
Sent to a process to identify user-defined conditions. |
SIGSEGV |
Sent to a process to notify of a segmentation fault. |
SIGPIPE |
Sent to a process when it has attempted to write to a disconnected pipe. |
SIGALRM |
Sent to a process when a system timer elapses. |
SIGTERM |
Sent to a process to request termination. |
SIGCHLD |
Sent to a process when a child process terminates. |
SIGSTKFLT |
Sent to a process to indicate a stack fault on a coprocessor. |
SIGCONT |
Sent to instruct the operating system to continue a paused process. |
SIGSTOP |
Sent to instruct the operating system to halt a process. |
SIGTSTP |
Sent to a process to request it to stop. |
SIGBREAK |
Sent to indicate when a user wishes to interrupt a process. |
SIGTTIN |
Sent to a process when it reads from the TTY while in the background. |
SIGTTOU |
Sent to a process when it writes to the TTY while in the background. |
SIGURG |
Sent to a process when a socket has urgent data to read. |
SIGXCPU |
Sent to a process when it has exceeded its limit on CPU usage. |
SIGXFSZ |
Sent to a process when it grows a file larger than the maximum allowed. |
SIGVTALRM |
Sent to a process when a virtual timer has elapsed. |
SIGPROF |
Sent to a process when a system timer has elapsed. |
SIGWINCH |
Sent to a process when the controlling terminal has changed its size. |
SIGIO |
Sent to a process when I/O is available. |
SIGPOLL |
Synonym for SIGIO |
SIGLOST |
Sent to a process when a file lock has been lost. |
SIGPWR |
Sent to a process to notify of a power failure. |
SIGINFO |
Synonym for SIGPWR |
SIGSYS |
Sent to a process to notify of a bad argument. |
SIGUNUSED |
Synonym for SIGSYS |
错误常量#>
【Error constants】
以下错误常量由 os.constants.errno 导出。
【The following error constants are exported by os.constants.errno.】
POSIX 错误常量#>
【POSIX error constants】
| Constant | Description |
|---|---|
E2BIG |
Indicates that the list of arguments is longer than expected. |
EACCES |
Indicates that the operation did not have sufficient permissions. |
EADDRINUSE |
Indicates that the network address is already in use. |
EADDRNOTAVAIL |
Indicates that the network address is currently unavailable for use. |
EAFNOSUPPORT |
Indicates that the network address family is not supported. |
EAGAIN |
Indicates that there is no data available and to try the operation again later. |
EALREADY |
Indicates that the socket already has a pending connection in progress. |
EBADF |
Indicates that a file descriptor is not valid. |
EBADMSG |
Indicates an invalid data message. |
EBUSY |
Indicates that a device or resource is busy. |
ECANCELED |
Indicates that an operation was canceled. |
ECHILD |
Indicates that there are no child processes. |
ECONNABORTED |
Indicates that the network connection has been aborted. |
ECONNREFUSED |
Indicates that the network connection has been refused. |
ECONNRESET |
Indicates that the network connection has been reset. |
EDEADLK |
Indicates that a resource deadlock has been avoided. |
EDESTADDRREQ |
Indicates that a destination address is required. |
EDOM |
Indicates that an argument is out of the domain of the function. |
EDQUOT |
Indicates that the disk quota has been exceeded. |
EEXIST |
Indicates that the file already exists. |
EFAULT |
Indicates an invalid pointer address. |
EFBIG |
Indicates that the file is too large. |
EHOSTUNREACH |
Indicates that the host is unreachable. |
EIDRM |
Indicates that the identifier has been removed. |
EILSEQ |
Indicates an illegal byte sequence. |
EINPROGRESS |
Indicates that an operation is already in progress. |
EINTR |
Indicates that a function call was interrupted. |
EINVAL |
Indicates that an invalid argument was provided. |
EIO |
Indicates an otherwise unspecified I/O error. |
EISCONN |
Indicates that the socket is connected. |
EISDIR |
Indicates that the path is a directory. |
ELOOP |
Indicates too many levels of symbolic links in a path. |
EMFILE |
Indicates that there are too many open files. |
EMLINK |
Indicates that there are too many hard links to a file. |
EMSGSIZE |
Indicates that the provided message is too long. |
EMULTIHOP |
Indicates that a multihop was attempted. |
ENAMETOOLONG |
Indicates that the filename is too long. |
ENETDOWN |
Indicates that the network is down. |
ENETRESET |
Indicates that the connection has been aborted by the network. |
ENETUNREACH |
Indicates that the network is unreachable. |
ENFILE |
Indicates too many open files in the system. |
ENOBUFS |
Indicates that no buffer space is available. |
ENODATA |
Indicates that no message is available on the stream head read queue. |
ENODEV |
Indicates that there is no such device. |
ENOENT |
Indicates that there is no such file or directory. |
ENOEXEC |
Indicates an exec format error. |
ENOLCK |
Indicates that there are no locks available. |
ENOLINK |
Indications that a link has been severed. |
ENOMEM |
Indicates that there is not enough space. |
ENOMSG |
Indicates that there is no message of the desired type. |
ENOPROTOOPT |
Indicates that a given protocol is not available. |
ENOSPC |
Indicates that there is no space available on the device. |
ENOSR |
Indicates that there are no stream resources available. |
ENOSTR |
Indicates that a given resource is not a stream. |
ENOSYS |
Indicates that a function has not been implemented. |
ENOTCONN |
Indicates that the socket is not connected. |
ENOTDIR |
Indicates that the path is not a directory. |
ENOTEMPTY |
Indicates that the directory is not empty. |
ENOTSOCK |
Indicates that the given item is not a socket. |
ENOTSUP |
Indicates that a given operation is not supported. |
ENOTTY |
Indicates an inappropriate I/O control operation. |
ENXIO |
Indicates no such device or address. |
EOPNOTSUPP |
Indicates that an operation is not supported on the socket. Although
ENOTSUP and EOPNOTSUPP have the same value
on Linux, according to POSIX.1 these error values should be distinct.) |
EOVERFLOW |
Indicates that a value is too large to be stored in a given data type. |
EPERM |
Indicates that the operation is not permitted. |
EPIPE |
Indicates a broken pipe. |
EPROTO |
Indicates a protocol error. |
EPROTONOSUPPORT |
Indicates that a protocol is not supported. |
EPROTOTYPE |
Indicates the wrong type of protocol for a socket. |
ERANGE |
Indicates that the results are too large. |
EROFS |
Indicates that the file system is read only. |
ESPIPE |
Indicates an invalid seek operation. |
ESRCH |
Indicates that there is no such process. |
ESTALE |
Indicates that the file handle is stale. |
ETIME |
Indicates an expired timer. |
ETIMEDOUT |
Indicates that the connection timed out. |
ETXTBSY |
Indicates that a text file is busy. |
EWOULDBLOCK |
Indicates that the operation would block. |
EXDEV |
Indicates an improper link. |
Windows 特定的错误常量#>
【Windows-specific error constants】
以下错误码特定于 Windows 操作系统。
【The following error codes are specific to the Windows operating system.】
| Constant | Description |
|---|---|
WSAEINTR |
Indicates an interrupted function call. |
WSAEBADF |
Indicates an invalid file handle. |
WSAEACCES |
Indicates insufficient permissions to complete the operation. |
WSAEFAULT |
Indicates an invalid pointer address. |
WSAEINVAL |
Indicates that an invalid argument was passed. |
WSAEMFILE |
Indicates that there are too many open files. |
WSAEWOULDBLOCK |
Indicates that a resource is temporarily unavailable. |
WSAEINPROGRESS |
Indicates that an operation is currently in progress. |
WSAEALREADY |
Indicates that an operation is already in progress. |
WSAENOTSOCK |
Indicates that the resource is not a socket. |
WSAEDESTADDRREQ |
Indicates that a destination address is required. |
WSAEMSGSIZE |
Indicates that the message size is too long. |
WSAEPROTOTYPE |
Indicates the wrong protocol type for the socket. |
WSAENOPROTOOPT |
Indicates a bad protocol option. |
WSAEPROTONOSUPPORT |
Indicates that the protocol is not supported. |
WSAESOCKTNOSUPPORT |
Indicates that the socket type is not supported. |
WSAEOPNOTSUPP |
Indicates that the operation is not supported. |
WSAEPFNOSUPPORT |
Indicates that the protocol family is not supported. |
WSAEAFNOSUPPORT |
Indicates that the address family is not supported. |
WSAEADDRINUSE |
Indicates that the network address is already in use. |
WSAEADDRNOTAVAIL |
Indicates that the network address is not available. |
WSAENETDOWN |
Indicates that the network is down. |
WSAENETUNREACH |
Indicates that the network is unreachable. |
WSAENETRESET |
Indicates that the network connection has been reset. |
WSAECONNABORTED |
Indicates that the connection has been aborted. |
WSAECONNRESET |
Indicates that the connection has been reset by the peer. |
WSAENOBUFS |
Indicates that there is no buffer space available. |
WSAEISCONN |
Indicates that the socket is already connected. |
WSAENOTCONN |
Indicates that the socket is not connected. |
WSAESHUTDOWN |
Indicates that data cannot be sent after the socket has been shutdown. |
WSAETOOMANYREFS |
Indicates that there are too many references. |
WSAETIMEDOUT |
Indicates that the connection has timed out. |
WSAECONNREFUSED |
Indicates that the connection has been refused. |
WSAELOOP |
Indicates that a name cannot be translated. |
WSAENAMETOOLONG |
Indicates that a name was too long. |
WSAEHOSTDOWN |
Indicates that a network host is down. |
WSAEHOSTUNREACH |
Indicates that there is no route to a network host. |
WSAENOTEMPTY |
Indicates that the directory is not empty. |
WSAEPROCLIM |
Indicates that there are too many processes. |
WSAEUSERS |
Indicates that the user quota has been exceeded. |
WSAEDQUOT |
Indicates that the disk quota has been exceeded. |
WSAESTALE |
Indicates a stale file handle reference. |
WSAEREMOTE |
Indicates that the item is remote. |
WSASYSNOTREADY |
Indicates that the network subsystem is not ready. |
WSAVERNOTSUPPORTED |
Indicates that the winsock.dll version is out of
range. |
WSANOTINITIALISED |
Indicates that successful WSAStartup has not yet been performed. |
WSAEDISCON |
Indicates that a graceful shutdown is in progress. |
WSAENOMORE |
Indicates that there are no more results. |
WSAECANCELLED |
Indicates that an operation has been canceled. |
WSAEINVALIDPROCTABLE |
Indicates that the procedure call table is invalid. |
WSAEINVALIDPROVIDER |
Indicates an invalid service provider. |
WSAEPROVIDERFAILEDINIT |
Indicates that the service provider failed to initialized. |
WSASYSCALLFAILURE |
Indicates a system call failure. |
WSASERVICE_NOT_FOUND |
Indicates that a service was not found. |
WSATYPE_NOT_FOUND |
Indicates that a class type was not found. |
WSA_E_NO_MORE |
Indicates that there are no more results. |
WSA_E_CANCELLED |
Indicates that the call was canceled. |
WSAEREFUSED |
Indicates that a database query was refused. |
dlopen 常量#>
【dlopen constants】
如果操作系统支持,以下常量会在 os.constants.dlopen 中导出。详细信息请参见 dlopen(3)。
【If available on the operating system, the following constants
are exported in os.constants.dlopen. See dlopen(3) for detailed
information.】
| 常量 | 描述 |
|---|---|
RTLD_LAZY |
执行延迟绑定。Node.js 默认设置此标志。 |
RTLD_NOW |
在 dlopen(3) 返回之前解析库中所有未定义的符号。 |
RTLD_GLOBAL |
库定义的符号将可用于随后加载的库的符号解析。 |
RTLD_LOCAL |
与 RTLD_GLOBAL 相反。如果未指定任何标志,这是默认行为。 |
RTLD_DEEPBIND |
让一个自包含库优先使用其自身的符号,而不是之前加载的库中的符号。 |
优先级常量#>
【Priority constants】
os.constants.priority 导出了以下进程调度常量。
【The following process scheduling constants are exported by
os.constants.priority.】
| Constant | Description |
|---|---|
PRIORITY_LOW |
The lowest process scheduling priority. This corresponds to
IDLE_PRIORITY_CLASS on Windows, and a nice value of
19 on all other platforms. |
PRIORITY_BELOW_NORMAL |
The process scheduling priority above PRIORITY_LOW and
below PRIORITY_NORMAL. This corresponds to
BELOW_NORMAL_PRIORITY_CLASS on Windows, and a nice value of
10 on all other platforms. |
PRIORITY_NORMAL |
The default process scheduling priority. This corresponds to
NORMAL_PRIORITY_CLASS on Windows, and a nice value of
0 on all other platforms. |
PRIORITY_ABOVE_NORMAL |
The process scheduling priority above PRIORITY_NORMAL and
below PRIORITY_HIGH. This corresponds to
ABOVE_NORMAL_PRIORITY_CLASS on Windows, and a nice value of
-7 on all other platforms. |
PRIORITY_HIGH |
The process scheduling priority above PRIORITY_ABOVE_NORMAL
and below PRIORITY_HIGHEST. This corresponds to
HIGH_PRIORITY_CLASS on Windows, and a nice value of
-14 on all other platforms. |
PRIORITY_HIGHEST |
The highest process scheduling priority. This corresponds to
REALTIME_PRIORITY_CLASS on Windows, and a nice value of
-20 on all other platforms. |
libuv 常量#>
【libuv constants】
| Constant | Description |
|---|---|
UV_UDP_REUSEADDR |