• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# OS
2
3<!--introduced_in=v0.10.0-->
4
5> Stability: 2 - Stable
6
7<!-- source_link=lib/os.js -->
8
9The `node:os` module provides operating system-related utility methods and
10properties. It can be accessed using:
11
12```js
13const os = require('node:os');
14```
15
16## `os.EOL`
17
18<!-- YAML
19added: v0.7.8
20-->
21
22* {string}
23
24The operating system-specific end-of-line marker.
25
26* `\n` on POSIX
27* `\r\n` on Windows
28
29## `os.availableParallelism()`
30
31<!-- YAML
32added: v18.14.0
33-->
34
35* Returns: {integer}
36
37Returns an estimate of the default amount of parallelism a program should use.
38Always returns a value greater than zero.
39
40This function is a small wrapper about libuv's [`uv_available_parallelism()`][].
41
42## `os.arch()`
43
44<!-- YAML
45added: v0.5.0
46-->
47
48* Returns: {string}
49
50Returns the operating system CPU architecture for which the Node.js binary was
51compiled. Possible values are `'arm'`, `'arm64'`, `'ia32'`, `'mips'`,
52`'mipsel'`, `'ppc'`, `'ppc64'`, `'s390'`, `'s390x'`, and `'x64'`.
53
54The return value is equivalent to [`process.arch`][].
55
56## `os.constants`
57
58<!-- YAML
59added: v6.3.0
60-->
61
62* {Object}
63
64Contains commonly used operating system-specific constants for error codes,
65process signals, and so on. The specific constants defined are described in
66[OS constants](#os-constants).
67
68## `os.cpus()`
69
70<!-- YAML
71added: v0.3.3
72-->
73
74* Returns: {Object\[]}
75
76Returns an array of objects containing information about each logical CPU core.
77The array will be empty if no CPU information is available, such as if the
78`/proc` file system is unavailable.
79
80The properties included on each object include:
81
82* `model` {string}
83* `speed` {number} (in MHz)
84* `times` {Object}
85  * `user` {number} The number of milliseconds the CPU has spent in user mode.
86  * `nice` {number} The number of milliseconds the CPU has spent in nice mode.
87  * `sys` {number} The number of milliseconds the CPU has spent in sys mode.
88  * `idle` {number} The number of milliseconds the CPU has spent in idle mode.
89  * `irq` {number} The number of milliseconds the CPU has spent in irq mode.
90
91<!-- eslint-disable semi -->
92
93```js
94[
95  {
96    model: 'Intel(R) Core(TM) i7 CPU         860  @ 2.80GHz',
97    speed: 2926,
98    times: {
99      user: 252020,
100      nice: 0,
101      sys: 30340,
102      idle: 1070356870,
103      irq: 0,
104    },
105  },
106  {
107    model: 'Intel(R) Core(TM) i7 CPU         860  @ 2.80GHz',
108    speed: 2926,
109    times: {
110      user: 306960,
111      nice: 0,
112      sys: 26980,
113      idle: 1071569080,
114      irq: 0,
115    },
116  },
117  {
118    model: 'Intel(R) Core(TM) i7 CPU         860  @ 2.80GHz',
119    speed: 2926,
120    times: {
121      user: 248450,
122      nice: 0,
123      sys: 21750,
124      idle: 1070919370,
125      irq: 0,
126    },
127  },
128  {
129    model: 'Intel(R) Core(TM) i7 CPU         860  @ 2.80GHz',
130    speed: 2926,
131    times: {
132      user: 256880,
133      nice: 0,
134      sys: 19430,
135      idle: 1070905480,
136      irq: 20,
137    },
138  },
139]
140```
141
142`nice` values are POSIX-only. On Windows, the `nice` values of all processors
143are always 0.
144
145`os.cpus().length` should not be used to calculate the amount of parallelism
146available to an application. Use
147[`os.availableParallelism()`](#osavailableparallelism) for this purpose.
148
149## `os.devNull`
150
151<!-- YAML
152added:
153  - v16.3.0
154  - v14.18.0
155-->
156
157* {string}
158
159The platform-specific file path of the null device.
160
161* `\\.\nul` on Windows
162* `/dev/null` on POSIX
163
164## `os.endianness()`
165
166<!-- YAML
167added: v0.9.4
168-->
169
170* Returns: {string}
171
172Returns a string identifying the endianness of the CPU for which the Node.js
173binary was compiled.
174
175Possible values are `'BE'` for big endian and `'LE'` for little endian.
176
177## `os.freemem()`
178
179<!-- YAML
180added: v0.3.3
181-->
182
183* Returns: {integer}
184
185Returns the amount of free system memory in bytes as an integer.
186
187## `os.getPriority([pid])`
188
189<!-- YAML
190added: v10.10.0
191-->
192
193* `pid` {integer} The process ID to retrieve scheduling priority for.
194  **Default:** `0`.
195* Returns: {integer}
196
197Returns the scheduling priority for the process specified by `pid`. If `pid` is
198not provided or is `0`, the priority of the current process is returned.
199
200## `os.homedir()`
201
202<!-- YAML
203added: v2.3.0
204-->
205
206* Returns: {string}
207
208Returns the string path of the current user's home directory.
209
210On POSIX, it uses the `$HOME` environment variable if defined. Otherwise it
211uses the [effective UID][EUID] to look up the user's home directory.
212
213On Windows, it uses the `USERPROFILE` environment variable if defined.
214Otherwise it uses the path to the profile directory of the current user.
215
216## `os.hostname()`
217
218<!-- YAML
219added: v0.3.3
220-->
221
222* Returns: {string}
223
224Returns the host name of the operating system as a string.
225
226## `os.loadavg()`
227
228<!-- YAML
229added: v0.3.3
230-->
231
232* Returns: {number\[]}
233
234Returns an array containing the 1, 5, and 15 minute load averages.
235
236The load average is a measure of system activity calculated by the operating
237system and expressed as a fractional number.
238
239The load average is a Unix-specific concept. On Windows, the return value is
240always `[0, 0, 0]`.
241
242## `os.machine()`
243
244<!-- YAML
245added: v18.9.0
246-->
247
248* Returns {string}
249
250Returns the machine type as a string, such as `arm`, `arm64`, `aarch64`,
251`mips`, `mips64`, `ppc64`, `ppc64le`, `s390`, `s390x`, `i386`, `i686`, `x86_64`.
252
253On POSIX systems, the machine type is determined by calling
254[`uname(3)`][]. On Windows, `RtlGetVersion()` is used, and if it is not
255available, `GetVersionExW()` will be used. See
256<https://en.wikipedia.org/wiki/Uname#Examples> for more information.
257
258## `os.networkInterfaces()`
259
260<!-- YAML
261added: v0.6.0
262changes:
263  - version: v18.4.0
264    pr-url: https://github.com/nodejs/node/pull/43054
265    description: The `family` property now returns a string instead of a number.
266  - version: v18.0.0
267    pr-url: https://github.com/nodejs/node/pull/41431
268    description: The `family` property now returns a number instead of a string.
269-->
270
271* Returns: {Object}
272
273Returns an object containing network interfaces that have been assigned a
274network address.
275
276Each key on the returned object identifies a network interface. The associated
277value is an array of objects that each describe an assigned network address.
278
279The properties available on the assigned network address object include:
280
281* `address` {string} The assigned IPv4 or IPv6 address
282* `netmask` {string} The IPv4 or IPv6 network mask
283* `family` {string} Either `IPv4` or `IPv6`
284* `mac` {string} The MAC address of the network interface
285* `internal` {boolean} `true` if the network interface is a loopback or
286  similar interface that is not remotely accessible; otherwise `false`
287* `scopeid` {number} The numeric IPv6 scope ID (only specified when `family`
288  is `IPv6`)
289* `cidr` {string} The assigned IPv4 or IPv6 address with the routing prefix
290  in CIDR notation. If the `netmask` is invalid, this property is set
291  to `null`.
292
293<!-- eslint-skip -->
294
295```js
296{
297  lo: [
298    {
299      address: '127.0.0.1',
300      netmask: '255.0.0.0',
301      family: 'IPv4',
302      mac: '00:00:00:00:00:00',
303      internal: true,
304      cidr: '127.0.0.1/8'
305    },
306    {
307      address: '::1',
308      netmask: 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff',
309      family: 'IPv6',
310      mac: '00:00:00:00:00:00',
311      scopeid: 0,
312      internal: true,
313      cidr: '::1/128'
314    }
315  ],
316  eth0: [
317    {
318      address: '192.168.1.108',
319      netmask: '255.255.255.0',
320      family: 'IPv4',
321      mac: '01:02:03:0a:0b:0c',
322      internal: false,
323      cidr: '192.168.1.108/24'
324    },
325    {
326      address: 'fe80::a00:27ff:fe4e:66a1',
327      netmask: 'ffff:ffff:ffff:ffff::',
328      family: 'IPv6',
329      mac: '01:02:03:0a:0b:0c',
330      scopeid: 1,
331      internal: false,
332      cidr: 'fe80::a00:27ff:fe4e:66a1/64'
333    }
334  ]
335}
336```
337
338## `os.platform()`
339
340<!-- YAML
341added: v0.5.0
342-->
343
344* Returns: {string}
345
346Returns a string identifying the operating system platform for which
347the Node.js binary was compiled. The value is set at compile time.
348Possible values are `'aix'`, `'darwin'`, `'freebsd'`,`'linux'`,
349`'openbsd'`, `'sunos'`, and `'win32'`.
350
351The return value is equivalent to [`process.platform`][].
352
353The value `'android'` may also be returned if Node.js is built on the Android
354operating system. [Android support is experimental][Android building].
355
356## `os.release()`
357
358<!-- YAML
359added: v0.3.3
360-->
361
362* Returns: {string}
363
364Returns the operating system as a string.
365
366On POSIX systems, the operating system release is determined by calling
367[`uname(3)`][]. On Windows, `GetVersionExW()` is used. See
368<https://en.wikipedia.org/wiki/Uname#Examples> for more information.
369
370## `os.setPriority([pid, ]priority)`
371
372<!-- YAML
373added: v10.10.0
374-->
375
376* `pid` {integer} The process ID to set scheduling priority for.
377  **Default:** `0`.
378* `priority` {integer} The scheduling priority to assign to the process.
379
380Attempts to set the scheduling priority for the process specified by `pid`. If
381`pid` is not provided or is `0`, the process ID of the current process is used.
382
383The `priority` input must be an integer between `-20` (high priority) and `19`
384(low priority). Due to differences between Unix priority levels and Windows
385priority classes, `priority` is mapped to one of six priority constants in
386`os.constants.priority`. When retrieving a process priority level, this range
387mapping may cause the return value to be slightly different on Windows. To avoid
388confusion, set `priority` to one of the priority constants.
389
390On Windows, setting priority to `PRIORITY_HIGHEST` requires elevated user
391privileges. Otherwise the set priority will be silently reduced to
392`PRIORITY_HIGH`.
393
394## `os.tmpdir()`
395
396<!-- YAML
397added: v0.9.9
398changes:
399  - version: v2.0.0
400    pr-url: https://github.com/nodejs/node/pull/747
401    description: This function is now cross-platform consistent and no longer
402                 returns a path with a trailing slash on any platform.
403-->
404
405* Returns: {string}
406
407Returns the operating system's default directory for temporary files as a
408string.
409
410## `os.totalmem()`
411
412<!-- YAML
413added: v0.3.3
414-->
415
416* Returns: {integer}
417
418Returns the total amount of system memory in bytes as an integer.
419
420## `os.type()`
421
422<!-- YAML
423added: v0.3.3
424-->
425
426* Returns: {string}
427
428Returns the operating system name as returned by [`uname(3)`][]. For example, it
429returns `'Linux'` on Linux, `'Darwin'` on macOS, and `'Windows_NT'` on Windows.
430
431See <https://en.wikipedia.org/wiki/Uname#Examples> for additional information
432about the output of running [`uname(3)`][] on various operating systems.
433
434## `os.uptime()`
435
436<!-- YAML
437added: v0.3.3
438changes:
439  - version: v10.0.0
440    pr-url: https://github.com/nodejs/node/pull/20129
441    description: The result of this function no longer contains a fraction
442                 component on Windows.
443-->
444
445* Returns: {integer}
446
447Returns the system uptime in number of seconds.
448
449## `os.userInfo([options])`
450
451<!-- YAML
452added: v6.0.0
453-->
454
455* `options` {Object}
456  * `encoding` {string} Character encoding used to interpret resulting strings.
457    If `encoding` is set to `'buffer'`, the `username`, `shell`, and `homedir`
458    values will be `Buffer` instances. **Default:** `'utf8'`.
459* Returns: {Object}
460
461Returns information about the currently effective user. On POSIX platforms,
462this is typically a subset of the password file. The returned object includes
463the `username`, `uid`, `gid`, `shell`, and `homedir`. On Windows, the `uid` and
464`gid` fields are `-1`, and `shell` is `null`.
465
466The value of `homedir` returned by `os.userInfo()` is provided by the operating
467system. This differs from the result of `os.homedir()`, which queries
468environment variables for the home directory before falling back to the
469operating system response.
470
471Throws a [`SystemError`][] if a user has no `username` or `homedir`.
472
473## `os.version()`
474
475<!-- YAML
476added:
477 - v13.11.0
478 - v12.17.0
479-->
480
481* Returns {string}
482
483Returns a string identifying the kernel version.
484
485On POSIX systems, the operating system release is determined by calling
486[`uname(3)`][]. On Windows, `RtlGetVersion()` is used, and if it is not
487available, `GetVersionExW()` will be used. See
488<https://en.wikipedia.org/wiki/Uname#Examples> for more information.
489
490## OS constants
491
492The following constants are exported by `os.constants`.
493
494Not all constants will be available on every operating system.
495
496### Signal constants
497
498<!-- YAML
499changes:
500  - version: v5.11.0
501    pr-url: https://github.com/nodejs/node/pull/6093
502    description: Added support for `SIGINFO`.
503-->
504
505The following signal constants are exported by `os.constants.signals`.
506
507<table>
508  <tr>
509    <th>Constant</th>
510    <th>Description</th>
511  </tr>
512  <tr>
513    <td><code>SIGHUP</code></td>
514    <td>Sent to indicate when a controlling terminal is closed or a parent
515    process exits.</td>
516  </tr>
517  <tr>
518    <td><code>SIGINT</code></td>
519    <td>Sent to indicate when a user wishes to interrupt a process
520    (<kbd>Ctrl</kbd>+<kbd>C</kbd>).</td>
521  </tr>
522  <tr>
523    <td><code>SIGQUIT</code></td>
524    <td>Sent to indicate when a user wishes to terminate a process and perform a
525    core dump.</td>
526  </tr>
527  <tr>
528    <td><code>SIGILL</code></td>
529    <td>Sent to a process to notify that it has attempted to perform an illegal,
530    malformed, unknown, or privileged instruction.</td>
531  </tr>
532  <tr>
533    <td><code>SIGTRAP</code></td>
534    <td>Sent to a process when an exception has occurred.</td>
535  </tr>
536  <tr>
537    <td><code>SIGABRT</code></td>
538    <td>Sent to a process to request that it abort.</td>
539  </tr>
540  <tr>
541    <td><code>SIGIOT</code></td>
542    <td>Synonym for <code>SIGABRT</code></td>
543  </tr>
544  <tr>
545    <td><code>SIGBUS</code></td>
546    <td>Sent to a process to notify that it has caused a bus error.</td>
547  </tr>
548  <tr>
549    <td><code>SIGFPE</code></td>
550    <td>Sent to a process to notify that it has performed an illegal arithmetic
551    operation.</td>
552  </tr>
553  <tr>
554    <td><code>SIGKILL</code></td>
555    <td>Sent to a process to terminate it immediately.</td>
556  </tr>
557  <tr>
558    <td><code>SIGUSR1</code> <code>SIGUSR2</code></td>
559    <td>Sent to a process to identify user-defined conditions.</td>
560  </tr>
561  <tr>
562    <td><code>SIGSEGV</code></td>
563    <td>Sent to a process to notify of a segmentation fault.</td>
564  </tr>
565  <tr>
566    <td><code>SIGPIPE</code></td>
567    <td>Sent to a process when it has attempted to write to a disconnected
568    pipe.</td>
569  </tr>
570  <tr>
571    <td><code>SIGALRM</code></td>
572    <td>Sent to a process when a system timer elapses.</td>
573  </tr>
574  <tr>
575    <td><code>SIGTERM</code></td>
576    <td>Sent to a process to request termination.</td>
577  </tr>
578  <tr>
579    <td><code>SIGCHLD</code></td>
580    <td>Sent to a process when a child process terminates.</td>
581  </tr>
582  <tr>
583    <td><code>SIGSTKFLT</code></td>
584    <td>Sent to a process to indicate a stack fault on a coprocessor.</td>
585  </tr>
586  <tr>
587    <td><code>SIGCONT</code></td>
588    <td>Sent to instruct the operating system to continue a paused process.</td>
589  </tr>
590  <tr>
591    <td><code>SIGSTOP</code></td>
592    <td>Sent to instruct the operating system to halt a process.</td>
593  </tr>
594  <tr>
595    <td><code>SIGTSTP</code></td>
596    <td>Sent to a process to request it to stop.</td>
597  </tr>
598  <tr>
599    <td><code>SIGBREAK</code></td>
600    <td>Sent to indicate when a user wishes to interrupt a process.</td>
601  </tr>
602  <tr>
603    <td><code>SIGTTIN</code></td>
604    <td>Sent to a process when it reads from the TTY while in the
605    background.</td>
606  </tr>
607  <tr>
608    <td><code>SIGTTOU</code></td>
609    <td>Sent to a process when it writes to the TTY while in the
610    background.</td>
611  </tr>
612  <tr>
613    <td><code>SIGURG</code></td>
614    <td>Sent to a process when a socket has urgent data to read.</td>
615  </tr>
616  <tr>
617    <td><code>SIGXCPU</code></td>
618    <td>Sent to a process when it has exceeded its limit on CPU usage.</td>
619  </tr>
620  <tr>
621    <td><code>SIGXFSZ</code></td>
622    <td>Sent to a process when it grows a file larger than the maximum
623    allowed.</td>
624  </tr>
625  <tr>
626    <td><code>SIGVTALRM</code></td>
627    <td>Sent to a process when a virtual timer has elapsed.</td>
628  </tr>
629  <tr>
630    <td><code>SIGPROF</code></td>
631    <td>Sent to a process when a system timer has elapsed.</td>
632  </tr>
633  <tr>
634    <td><code>SIGWINCH</code></td>
635    <td>Sent to a process when the controlling terminal has changed its
636    size.</td>
637  </tr>
638  <tr>
639    <td><code>SIGIO</code></td>
640    <td>Sent to a process when I/O is available.</td>
641  </tr>
642  <tr>
643    <td><code>SIGPOLL</code></td>
644    <td>Synonym for <code>SIGIO</code></td>
645  </tr>
646  <tr>
647    <td><code>SIGLOST</code></td>
648    <td>Sent to a process when a file lock has been lost.</td>
649  </tr>
650  <tr>
651    <td><code>SIGPWR</code></td>
652    <td>Sent to a process to notify of a power failure.</td>
653  </tr>
654  <tr>
655    <td><code>SIGINFO</code></td>
656    <td>Synonym for <code>SIGPWR</code></td>
657  </tr>
658  <tr>
659    <td><code>SIGSYS</code></td>
660    <td>Sent to a process to notify of a bad argument.</td>
661  </tr>
662  <tr>
663    <td><code>SIGUNUSED</code></td>
664    <td>Synonym for <code>SIGSYS</code></td>
665  </tr>
666</table>
667
668### Error constants
669
670The following error constants are exported by `os.constants.errno`.
671
672#### POSIX error constants
673
674<table>
675  <tr>
676    <th>Constant</th>
677    <th>Description</th>
678  </tr>
679  <tr>
680    <td><code>E2BIG</code></td>
681    <td>Indicates that the list of arguments is longer than expected.</td>
682  </tr>
683  <tr>
684    <td><code>EACCES</code></td>
685    <td>Indicates that the operation did not have sufficient permissions.</td>
686  </tr>
687  <tr>
688    <td><code>EADDRINUSE</code></td>
689    <td>Indicates that the network address is already in use.</td>
690  </tr>
691  <tr>
692    <td><code>EADDRNOTAVAIL</code></td>
693    <td>Indicates that the network address is currently unavailable for
694    use.</td>
695  </tr>
696  <tr>
697    <td><code>EAFNOSUPPORT</code></td>
698    <td>Indicates that the network address family is not supported.</td>
699  </tr>
700  <tr>
701    <td><code>EAGAIN</code></td>
702    <td>Indicates that there is no data available and to try the
703    operation again later.</td>
704  </tr>
705  <tr>
706    <td><code>EALREADY</code></td>
707    <td>Indicates that the socket already has a pending connection in
708    progress.</td>
709  </tr>
710  <tr>
711    <td><code>EBADF</code></td>
712    <td>Indicates that a file descriptor is not valid.</td>
713  </tr>
714  <tr>
715    <td><code>EBADMSG</code></td>
716    <td>Indicates an invalid data message.</td>
717  </tr>
718  <tr>
719    <td><code>EBUSY</code></td>
720    <td>Indicates that a device or resource is busy.</td>
721  </tr>
722  <tr>
723    <td><code>ECANCELED</code></td>
724    <td>Indicates that an operation was canceled.</td>
725  </tr>
726  <tr>
727    <td><code>ECHILD</code></td>
728    <td>Indicates that there are no child processes.</td>
729  </tr>
730  <tr>
731    <td><code>ECONNABORTED</code></td>
732    <td>Indicates that the network connection has been aborted.</td>
733  </tr>
734  <tr>
735    <td><code>ECONNREFUSED</code></td>
736    <td>Indicates that the network connection has been refused.</td>
737  </tr>
738  <tr>
739    <td><code>ECONNRESET</code></td>
740    <td>Indicates that the network connection has been reset.</td>
741  </tr>
742  <tr>
743    <td><code>EDEADLK</code></td>
744    <td>Indicates that a resource deadlock has been avoided.</td>
745  </tr>
746  <tr>
747    <td><code>EDESTADDRREQ</code></td>
748    <td>Indicates that a destination address is required.</td>
749  </tr>
750  <tr>
751    <td><code>EDOM</code></td>
752    <td>Indicates that an argument is out of the domain of the function.</td>
753  </tr>
754  <tr>
755    <td><code>EDQUOT</code></td>
756    <td>Indicates that the disk quota has been exceeded.</td>
757  </tr>
758  <tr>
759    <td><code>EEXIST</code></td>
760    <td>Indicates that the file already exists.</td>
761  </tr>
762  <tr>
763    <td><code>EFAULT</code></td>
764    <td>Indicates an invalid pointer address.</td>
765  </tr>
766  <tr>
767    <td><code>EFBIG</code></td>
768    <td>Indicates that the file is too large.</td>
769  </tr>
770  <tr>
771    <td><code>EHOSTUNREACH</code></td>
772    <td>Indicates that the host is unreachable.</td>
773  </tr>
774  <tr>
775    <td><code>EIDRM</code></td>
776    <td>Indicates that the identifier has been removed.</td>
777  </tr>
778  <tr>
779    <td><code>EILSEQ</code></td>
780    <td>Indicates an illegal byte sequence.</td>
781  </tr>
782  <tr>
783    <td><code>EINPROGRESS</code></td>
784    <td>Indicates that an operation is already in progress.</td>
785  </tr>
786  <tr>
787    <td><code>EINTR</code></td>
788    <td>Indicates that a function call was interrupted.</td>
789  </tr>
790  <tr>
791    <td><code>EINVAL</code></td>
792    <td>Indicates that an invalid argument was provided.</td>
793  </tr>
794  <tr>
795    <td><code>EIO</code></td>
796    <td>Indicates an otherwise unspecified I/O error.</td>
797  </tr>
798  <tr>
799    <td><code>EISCONN</code></td>
800    <td>Indicates that the socket is connected.</td>
801  </tr>
802  <tr>
803    <td><code>EISDIR</code></td>
804    <td>Indicates that the path is a directory.</td>
805  </tr>
806  <tr>
807    <td><code>ELOOP</code></td>
808    <td>Indicates too many levels of symbolic links in a path.</td>
809  </tr>
810  <tr>
811    <td><code>EMFILE</code></td>
812    <td>Indicates that there are too many open files.</td>
813  </tr>
814  <tr>
815    <td><code>EMLINK</code></td>
816    <td>Indicates that there are too many hard links to a file.</td>
817  </tr>
818  <tr>
819    <td><code>EMSGSIZE</code></td>
820    <td>Indicates that the provided message is too long.</td>
821  </tr>
822  <tr>
823    <td><code>EMULTIHOP</code></td>
824    <td>Indicates that a multihop was attempted.</td>
825  </tr>
826  <tr>
827    <td><code>ENAMETOOLONG</code></td>
828    <td>Indicates that the filename is too long.</td>
829  </tr>
830  <tr>
831    <td><code>ENETDOWN</code></td>
832    <td>Indicates that the network is down.</td>
833  </tr>
834  <tr>
835    <td><code>ENETRESET</code></td>
836    <td>Indicates that the connection has been aborted by the network.</td>
837  </tr>
838  <tr>
839    <td><code>ENETUNREACH</code></td>
840    <td>Indicates that the network is unreachable.</td>
841  </tr>
842  <tr>
843    <td><code>ENFILE</code></td>
844    <td>Indicates too many open files in the system.</td>
845  </tr>
846  <tr>
847    <td><code>ENOBUFS</code></td>
848    <td>Indicates that no buffer space is available.</td>
849  </tr>
850  <tr>
851    <td><code>ENODATA</code></td>
852    <td>Indicates that no message is available on the stream head read
853    queue.</td>
854  </tr>
855  <tr>
856    <td><code>ENODEV</code></td>
857    <td>Indicates that there is no such device.</td>
858  </tr>
859  <tr>
860    <td><code>ENOENT</code></td>
861    <td>Indicates that there is no such file or directory.</td>
862  </tr>
863  <tr>
864    <td><code>ENOEXEC</code></td>
865    <td>Indicates an exec format error.</td>
866  </tr>
867  <tr>
868    <td><code>ENOLCK</code></td>
869    <td>Indicates that there are no locks available.</td>
870  </tr>
871  <tr>
872    <td><code>ENOLINK</code></td>
873    <td>Indications that a link has been severed.</td>
874  </tr>
875  <tr>
876    <td><code>ENOMEM</code></td>
877    <td>Indicates that there is not enough space.</td>
878  </tr>
879  <tr>
880    <td><code>ENOMSG</code></td>
881    <td>Indicates that there is no message of the desired type.</td>
882  </tr>
883  <tr>
884    <td><code>ENOPROTOOPT</code></td>
885    <td>Indicates that a given protocol is not available.</td>
886  </tr>
887  <tr>
888    <td><code>ENOSPC</code></td>
889    <td>Indicates that there is no space available on the device.</td>
890  </tr>
891  <tr>
892    <td><code>ENOSR</code></td>
893    <td>Indicates that there are no stream resources available.</td>
894  </tr>
895  <tr>
896    <td><code>ENOSTR</code></td>
897    <td>Indicates that a given resource is not a stream.</td>
898  </tr>
899  <tr>
900    <td><code>ENOSYS</code></td>
901    <td>Indicates that a function has not been implemented.</td>
902  </tr>
903  <tr>
904    <td><code>ENOTCONN</code></td>
905    <td>Indicates that the socket is not connected.</td>
906  </tr>
907  <tr>
908    <td><code>ENOTDIR</code></td>
909    <td>Indicates that the path is not a directory.</td>
910  </tr>
911  <tr>
912    <td><code>ENOTEMPTY</code></td>
913    <td>Indicates that the directory is not empty.</td>
914  </tr>
915  <tr>
916    <td><code>ENOTSOCK</code></td>
917    <td>Indicates that the given item is not a socket.</td>
918  </tr>
919  <tr>
920    <td><code>ENOTSUP</code></td>
921    <td>Indicates that a given operation is not supported.</td>
922  </tr>
923  <tr>
924    <td><code>ENOTTY</code></td>
925    <td>Indicates an inappropriate I/O control operation.</td>
926  </tr>
927  <tr>
928    <td><code>ENXIO</code></td>
929    <td>Indicates no such device or address.</td>
930  </tr>
931  <tr>
932    <td><code>EOPNOTSUPP</code></td>
933    <td>Indicates that an operation is not supported on the socket. Although
934    <code>ENOTSUP</code> and <code>EOPNOTSUPP</code> have the same value
935    on Linux, according to POSIX.1 these error values should be distinct.)</td>
936  </tr>
937  <tr>
938    <td><code>EOVERFLOW</code></td>
939    <td>Indicates that a value is too large to be stored in a given data
940    type.</td>
941  </tr>
942  <tr>
943    <td><code>EPERM</code></td>
944    <td>Indicates that the operation is not permitted.</td>
945  </tr>
946  <tr>
947    <td><code>EPIPE</code></td>
948    <td>Indicates a broken pipe.</td>
949  </tr>
950  <tr>
951    <td><code>EPROTO</code></td>
952    <td>Indicates a protocol error.</td>
953  </tr>
954  <tr>
955    <td><code>EPROTONOSUPPORT</code></td>
956    <td>Indicates that a protocol is not supported.</td>
957  </tr>
958  <tr>
959    <td><code>EPROTOTYPE</code></td>
960    <td>Indicates the wrong type of protocol for a socket.</td>
961  </tr>
962  <tr>
963    <td><code>ERANGE</code></td>
964    <td>Indicates that the results are too large.</td>
965  </tr>
966  <tr>
967    <td><code>EROFS</code></td>
968    <td>Indicates that the file system is read only.</td>
969  </tr>
970  <tr>
971    <td><code>ESPIPE</code></td>
972    <td>Indicates an invalid seek operation.</td>
973  </tr>
974  <tr>
975    <td><code>ESRCH</code></td>
976    <td>Indicates that there is no such process.</td>
977  </tr>
978  <tr>
979    <td><code>ESTALE</code></td>
980    <td>Indicates that the file handle is stale.</td>
981  </tr>
982  <tr>
983    <td><code>ETIME</code></td>
984    <td>Indicates an expired timer.</td>
985  </tr>
986  <tr>
987    <td><code>ETIMEDOUT</code></td>
988    <td>Indicates that the connection timed out.</td>
989  </tr>
990  <tr>
991    <td><code>ETXTBSY</code></td>
992    <td>Indicates that a text file is busy.</td>
993  </tr>
994  <tr>
995    <td><code>EWOULDBLOCK</code></td>
996    <td>Indicates that the operation would block.</td>
997  </tr>
998  <tr>
999    <td><code>EXDEV</code></td>
1000    <td>Indicates an improper link.</td>
1001  </tr>
1002</table>
1003
1004#### Windows-specific error constants
1005
1006The following error codes are specific to the Windows operating system.
1007
1008<table>
1009  <tr>
1010    <th>Constant</th>
1011    <th>Description</th>
1012  </tr>
1013  <tr>
1014    <td><code>WSAEINTR</code></td>
1015    <td>Indicates an interrupted function call.</td>
1016  </tr>
1017  <tr>
1018    <td><code>WSAEBADF</code></td>
1019    <td>Indicates an invalid file handle.</td>
1020  </tr>
1021  <tr>
1022    <td><code>WSAEACCES</code></td>
1023    <td>Indicates insufficient permissions to complete the operation.</td>
1024  </tr>
1025  <tr>
1026    <td><code>WSAEFAULT</code></td>
1027    <td>Indicates an invalid pointer address.</td>
1028  </tr>
1029  <tr>
1030    <td><code>WSAEINVAL</code></td>
1031    <td>Indicates that an invalid argument was passed.</td>
1032  </tr>
1033  <tr>
1034    <td><code>WSAEMFILE</code></td>
1035    <td>Indicates that there are too many open files.</td>
1036  </tr>
1037  <tr>
1038    <td><code>WSAEWOULDBLOCK</code></td>
1039    <td>Indicates that a resource is temporarily unavailable.</td>
1040  </tr>
1041  <tr>
1042    <td><code>WSAEINPROGRESS</code></td>
1043    <td>Indicates that an operation is currently in progress.</td>
1044  </tr>
1045  <tr>
1046    <td><code>WSAEALREADY</code></td>
1047    <td>Indicates that an operation is already in progress.</td>
1048  </tr>
1049  <tr>
1050    <td><code>WSAENOTSOCK</code></td>
1051    <td>Indicates that the resource is not a socket.</td>
1052  </tr>
1053  <tr>
1054    <td><code>WSAEDESTADDRREQ</code></td>
1055    <td>Indicates that a destination address is required.</td>
1056  </tr>
1057  <tr>
1058    <td><code>WSAEMSGSIZE</code></td>
1059    <td>Indicates that the message size is too long.</td>
1060  </tr>
1061  <tr>
1062    <td><code>WSAEPROTOTYPE</code></td>
1063    <td>Indicates the wrong protocol type for the socket.</td>
1064  </tr>
1065  <tr>
1066    <td><code>WSAENOPROTOOPT</code></td>
1067    <td>Indicates a bad protocol option.</td>
1068  </tr>
1069  <tr>
1070    <td><code>WSAEPROTONOSUPPORT</code></td>
1071    <td>Indicates that the protocol is not supported.</td>
1072  </tr>
1073  <tr>
1074    <td><code>WSAESOCKTNOSUPPORT</code></td>
1075    <td>Indicates that the socket type is not supported.</td>
1076  </tr>
1077  <tr>
1078    <td><code>WSAEOPNOTSUPP</code></td>
1079    <td>Indicates that the operation is not supported.</td>
1080  </tr>
1081  <tr>
1082    <td><code>WSAEPFNOSUPPORT</code></td>
1083    <td>Indicates that the protocol family is not supported.</td>
1084  </tr>
1085  <tr>
1086    <td><code>WSAEAFNOSUPPORT</code></td>
1087    <td>Indicates that the address family is not supported.</td>
1088  </tr>
1089  <tr>
1090    <td><code>WSAEADDRINUSE</code></td>
1091    <td>Indicates that the network address is already in use.</td>
1092  </tr>
1093  <tr>
1094    <td><code>WSAEADDRNOTAVAIL</code></td>
1095    <td>Indicates that the network address is not available.</td>
1096  </tr>
1097  <tr>
1098    <td><code>WSAENETDOWN</code></td>
1099    <td>Indicates that the network is down.</td>
1100  </tr>
1101  <tr>
1102    <td><code>WSAENETUNREACH</code></td>
1103    <td>Indicates that the network is unreachable.</td>
1104  </tr>
1105  <tr>
1106    <td><code>WSAENETRESET</code></td>
1107    <td>Indicates that the network connection has been reset.</td>
1108  </tr>
1109  <tr>
1110    <td><code>WSAECONNABORTED</code></td>
1111    <td>Indicates that the connection has been aborted.</td>
1112  </tr>
1113  <tr>
1114    <td><code>WSAECONNRESET</code></td>
1115    <td>Indicates that the connection has been reset by the peer.</td>
1116  </tr>
1117  <tr>
1118    <td><code>WSAENOBUFS</code></td>
1119    <td>Indicates that there is no buffer space available.</td>
1120  </tr>
1121  <tr>
1122    <td><code>WSAEISCONN</code></td>
1123    <td>Indicates that the socket is already connected.</td>
1124  </tr>
1125  <tr>
1126    <td><code>WSAENOTCONN</code></td>
1127    <td>Indicates that the socket is not connected.</td>
1128  </tr>
1129  <tr>
1130    <td><code>WSAESHUTDOWN</code></td>
1131    <td>Indicates that data cannot be sent after the socket has been
1132    shutdown.</td>
1133  </tr>
1134  <tr>
1135    <td><code>WSAETOOMANYREFS</code></td>
1136    <td>Indicates that there are too many references.</td>
1137  </tr>
1138  <tr>
1139    <td><code>WSAETIMEDOUT</code></td>
1140    <td>Indicates that the connection has timed out.</td>
1141  </tr>
1142  <tr>
1143    <td><code>WSAECONNREFUSED</code></td>
1144    <td>Indicates that the connection has been refused.</td>
1145  </tr>
1146  <tr>
1147    <td><code>WSAELOOP</code></td>
1148    <td>Indicates that a name cannot be translated.</td>
1149  </tr>
1150  <tr>
1151    <td><code>WSAENAMETOOLONG</code></td>
1152    <td>Indicates that a name was too long.</td>
1153  </tr>
1154  <tr>
1155    <td><code>WSAEHOSTDOWN</code></td>
1156    <td>Indicates that a network host is down.</td>
1157  </tr>
1158  <tr>
1159    <td><code>WSAEHOSTUNREACH</code></td>
1160    <td>Indicates that there is no route to a network host.</td>
1161  </tr>
1162  <tr>
1163    <td><code>WSAENOTEMPTY</code></td>
1164    <td>Indicates that the directory is not empty.</td>
1165  </tr>
1166  <tr>
1167    <td><code>WSAEPROCLIM</code></td>
1168    <td>Indicates that there are too many processes.</td>
1169  </tr>
1170  <tr>
1171    <td><code>WSAEUSERS</code></td>
1172    <td>Indicates that the user quota has been exceeded.</td>
1173  </tr>
1174  <tr>
1175    <td><code>WSAEDQUOT</code></td>
1176    <td>Indicates that the disk quota has been exceeded.</td>
1177  </tr>
1178  <tr>
1179    <td><code>WSAESTALE</code></td>
1180    <td>Indicates a stale file handle reference.</td>
1181  </tr>
1182  <tr>
1183    <td><code>WSAEREMOTE</code></td>
1184    <td>Indicates that the item is remote.</td>
1185  </tr>
1186  <tr>
1187    <td><code>WSASYSNOTREADY</code></td>
1188    <td>Indicates that the network subsystem is not ready.</td>
1189  </tr>
1190  <tr>
1191    <td><code>WSAVERNOTSUPPORTED</code></td>
1192    <td>Indicates that the <code>winsock.dll</code> version is out of
1193    range.</td>
1194  </tr>
1195  <tr>
1196    <td><code>WSANOTINITIALISED</code></td>
1197    <td>Indicates that successful WSAStartup has not yet been performed.</td>
1198  </tr>
1199  <tr>
1200    <td><code>WSAEDISCON</code></td>
1201    <td>Indicates that a graceful shutdown is in progress.</td>
1202  </tr>
1203  <tr>
1204    <td><code>WSAENOMORE</code></td>
1205    <td>Indicates that there are no more results.</td>
1206  </tr>
1207  <tr>
1208    <td><code>WSAECANCELLED</code></td>
1209    <td>Indicates that an operation has been canceled.</td>
1210  </tr>
1211  <tr>
1212    <td><code>WSAEINVALIDPROCTABLE</code></td>
1213    <td>Indicates that the procedure call table is invalid.</td>
1214  </tr>
1215  <tr>
1216    <td><code>WSAEINVALIDPROVIDER</code></td>
1217    <td>Indicates an invalid service provider.</td>
1218  </tr>
1219  <tr>
1220    <td><code>WSAEPROVIDERFAILEDINIT</code></td>
1221    <td>Indicates that the service provider failed to initialized.</td>
1222  </tr>
1223  <tr>
1224    <td><code>WSASYSCALLFAILURE</code></td>
1225    <td>Indicates a system call failure.</td>
1226  </tr>
1227  <tr>
1228    <td><code>WSASERVICE_NOT_FOUND</code></td>
1229    <td>Indicates that a service was not found.</td>
1230  </tr>
1231  <tr>
1232    <td><code>WSATYPE_NOT_FOUND</code></td>
1233    <td>Indicates that a class type was not found.</td>
1234  </tr>
1235  <tr>
1236    <td><code>WSA_E_NO_MORE</code></td>
1237    <td>Indicates that there are no more results.</td>
1238  </tr>
1239  <tr>
1240    <td><code>WSA_E_CANCELLED</code></td>
1241    <td>Indicates that the call was canceled.</td>
1242  </tr>
1243  <tr>
1244    <td><code>WSAEREFUSED</code></td>
1245    <td>Indicates that a database query was refused.</td>
1246  </tr>
1247</table>
1248
1249### dlopen constants
1250
1251If available on the operating system, the following constants
1252are exported in `os.constants.dlopen`. See dlopen(3) for detailed
1253information.
1254
1255<table>
1256  <tr>
1257    <th>Constant</th>
1258    <th>Description</th>
1259  </tr>
1260  <tr>
1261    <td><code>RTLD_LAZY</code></td>
1262    <td>Perform lazy binding. Node.js sets this flag by default.</td>
1263  </tr>
1264  <tr>
1265    <td><code>RTLD_NOW</code></td>
1266    <td>Resolve all undefined symbols in the library before dlopen(3)
1267    returns.</td>
1268  </tr>
1269  <tr>
1270    <td><code>RTLD_GLOBAL</code></td>
1271    <td>Symbols defined by the library will be made available for symbol
1272    resolution of subsequently loaded libraries.</td>
1273  </tr>
1274  <tr>
1275    <td><code>RTLD_LOCAL</code></td>
1276    <td>The converse of <code>RTLD_GLOBAL</code>. This is the default behavior
1277    if neither flag is specified.</td>
1278  </tr>
1279  <tr>
1280    <td><code>RTLD_DEEPBIND</code></td>
1281    <td>Make a self-contained library use its own symbols in preference to
1282    symbols from previously loaded libraries.</td>
1283  </tr>
1284</table>
1285
1286### Priority constants
1287
1288<!-- YAML
1289added: v10.10.0
1290-->
1291
1292The following process scheduling constants are exported by
1293`os.constants.priority`.
1294
1295<table>
1296  <tr>
1297    <th>Constant</th>
1298    <th>Description</th>
1299  </tr>
1300  <tr>
1301    <td><code>PRIORITY_LOW</code></td>
1302    <td>The lowest process scheduling priority. This corresponds to
1303    <code>IDLE_PRIORITY_CLASS</code> on Windows, and a nice value of
1304    <code>19</code> on all other platforms.</td>
1305  </tr>
1306  <tr>
1307    <td><code>PRIORITY_BELOW_NORMAL</code></td>
1308    <td>The process scheduling priority above <code>PRIORITY_LOW</code> and
1309    below <code>PRIORITY_NORMAL</code>. This corresponds to
1310    <code>BELOW_NORMAL_PRIORITY_CLASS</code> on Windows, and a nice value of
1311    <code>10</code> on all other platforms.</td>
1312  </tr>
1313  <tr>
1314    <td><code>PRIORITY_NORMAL</code></td>
1315    <td>The default process scheduling priority. This corresponds to
1316    <code>NORMAL_PRIORITY_CLASS</code> on Windows, and a nice value of
1317    <code>0</code> on all other platforms.</td>
1318  </tr>
1319  <tr>
1320    <td><code>PRIORITY_ABOVE_NORMAL</code></td>
1321    <td>The process scheduling priority above <code>PRIORITY_NORMAL</code> and
1322    below <code>PRIORITY_HIGH</code>. This corresponds to
1323    <code>ABOVE_NORMAL_PRIORITY_CLASS</code> on Windows, and a nice value of
1324    <code>-7</code> on all other platforms.</td>
1325  </tr>
1326  <tr>
1327    <td><code>PRIORITY_HIGH</code></td>
1328    <td>The process scheduling priority above <code>PRIORITY_ABOVE_NORMAL</code>
1329    and below <code>PRIORITY_HIGHEST</code>. This corresponds to
1330    <code>HIGH_PRIORITY_CLASS</code> on Windows, and a nice value of
1331    <code>-14</code> on all other platforms.</td>
1332  </tr>
1333  <tr>
1334    <td><code>PRIORITY_HIGHEST</code></td>
1335    <td>The highest process scheduling priority. This corresponds to
1336    <code>REALTIME_PRIORITY_CLASS</code> on Windows, and a nice value of
1337    <code>-20</code> on all other platforms.</td>
1338  </tr>
1339</table>
1340
1341### libuv constants
1342
1343<table>
1344  <tr>
1345    <th>Constant</th>
1346    <th>Description</th>
1347  </tr>
1348  <tr>
1349    <td><code>UV_UDP_REUSEADDR</code></td>
1350    <td></td>
1351  </tr>
1352</table>
1353
1354[Android building]: https://github.com/nodejs/node/blob/HEAD/BUILDING.md#androidandroid-based-devices-eg-firefox-os
1355[EUID]: https://en.wikipedia.org/wiki/User_identifier#Effective_user_ID
1356[`SystemError`]: errors.md#class-systemerror
1357[`process.arch`]: process.md#processarch
1358[`process.platform`]: process.md#processplatform
1359[`uname(3)`]: https://linux.die.net/man/3/uname
1360[`uv_available_parallelism()`]: https://docs.libuv.org/en/v1.x/misc.html#c.uv_available_parallelism
1361