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