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