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