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