%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/share/doc/nodejs/api/
Upload File :
Create Path :
Current File : //usr/share/doc/nodejs/api/process.html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <meta name="nodejs.org:node-version" content="v18.19.1">
  <title>Process | Node.js v18.19.1 Documentation</title>
  <link rel="stylesheet" href="assets/style.css">
  <link rel="stylesheet" href="assets/hljs.css">
  <script async defer src="assets/api.js" type="text/javascript"></script>
  __JS_FLAVORED_DYNAMIC_CSS__
</head>
<body class="alt apidoc" id="api-section-process">
  <div id="content" class="clearfix">
    <div id="column2" class="interior">
      <div id="intro" class="interior">
        <a href="index.html" title="Go back to the home page">
          Node.js
        </a>
      </div>
      <ul>
<li><a href="documentation.html" class="nav-documentation">About this documentation</a></li>
<li><a href="synopsis.html" class="nav-synopsis">Usage and example</a></li>
</ul>
<hr class="line"/>

<ul>
<li><a href="assert.html" class="nav-assert">Assertion testing</a></li>
<li><a href="async_context.html" class="nav-async_context">Asynchronous context tracking</a></li>
<li><a href="async_hooks.html" class="nav-async_hooks">Async hooks</a></li>
<li><a href="buffer.html" class="nav-buffer">Buffer</a></li>
<li><a href="addons.html" class="nav-addons">C++ addons</a></li>
<li><a href="n-api.html" class="nav-n-api">C/C++ addons with Node-API</a></li>
<li><a href="embedding.html" class="nav-embedding">C++ embedder API</a></li>
<li><a href="child_process.html" class="nav-child_process">Child processes</a></li>
<li><a href="cluster.html" class="nav-cluster">Cluster</a></li>
<li><a href="cli.html" class="nav-cli">Command-line options</a></li>
<li><a href="console.html" class="nav-console">Console</a></li>
<li><a href="corepack.html" class="nav-corepack">Corepack</a></li>
<li><a href="crypto.html" class="nav-crypto">Crypto</a></li>
<li><a href="debugger.html" class="nav-debugger">Debugger</a></li>
<li><a href="deprecations.html" class="nav-deprecations">Deprecated APIs</a></li>
<li><a href="diagnostics_channel.html" class="nav-diagnostics_channel">Diagnostics Channel</a></li>
<li><a href="dns.html" class="nav-dns">DNS</a></li>
<li><a href="domain.html" class="nav-domain">Domain</a></li>
<li><a href="errors.html" class="nav-errors">Errors</a></li>
<li><a href="events.html" class="nav-events">Events</a></li>
<li><a href="fs.html" class="nav-fs">File system</a></li>
<li><a href="globals.html" class="nav-globals">Globals</a></li>
<li><a href="http.html" class="nav-http">HTTP</a></li>
<li><a href="http2.html" class="nav-http2">HTTP/2</a></li>
<li><a href="https.html" class="nav-https">HTTPS</a></li>
<li><a href="inspector.html" class="nav-inspector">Inspector</a></li>
<li><a href="intl.html" class="nav-intl">Internationalization</a></li>
<li><a href="modules.html" class="nav-modules">Modules: CommonJS modules</a></li>
<li><a href="esm.html" class="nav-esm">Modules: ECMAScript modules</a></li>
<li><a href="module.html" class="nav-module">Modules: <code>node:module</code> API</a></li>
<li><a href="packages.html" class="nav-packages">Modules: Packages</a></li>
<li><a href="net.html" class="nav-net">Net</a></li>
<li><a href="os.html" class="nav-os">OS</a></li>
<li><a href="path.html" class="nav-path">Path</a></li>
<li><a href="perf_hooks.html" class="nav-perf_hooks">Performance hooks</a></li>
<li><a href="permissions.html" class="nav-permissions">Permissions</a></li>
<li><a href="process.html" class="nav-process active">Process</a></li>
<li><a href="punycode.html" class="nav-punycode">Punycode</a></li>
<li><a href="querystring.html" class="nav-querystring">Query strings</a></li>
<li><a href="readline.html" class="nav-readline">Readline</a></li>
<li><a href="repl.html" class="nav-repl">REPL</a></li>
<li><a href="report.html" class="nav-report">Report</a></li>
<li><a href="single-executable-applications.html" class="nav-single-executable-applications">Single executable applications</a></li>
<li><a href="stream.html" class="nav-stream">Stream</a></li>
<li><a href="string_decoder.html" class="nav-string_decoder">String decoder</a></li>
<li><a href="test.html" class="nav-test">Test runner</a></li>
<li><a href="timers.html" class="nav-timers">Timers</a></li>
<li><a href="tls.html" class="nav-tls">TLS/SSL</a></li>
<li><a href="tracing.html" class="nav-tracing">Trace events</a></li>
<li><a href="tty.html" class="nav-tty">TTY</a></li>
<li><a href="dgram.html" class="nav-dgram">UDP/datagram</a></li>
<li><a href="url.html" class="nav-url">URL</a></li>
<li><a href="util.html" class="nav-util">Utilities</a></li>
<li><a href="v8.html" class="nav-v8">V8</a></li>
<li><a href="vm.html" class="nav-vm">VM</a></li>
<li><a href="wasi.html" class="nav-wasi">WASI</a></li>
<li><a href="webcrypto.html" class="nav-webcrypto">Web Crypto API</a></li>
<li><a href="webstreams.html" class="nav-webstreams">Web Streams API</a></li>
<li><a href="worker_threads.html" class="nav-worker_threads">Worker threads</a></li>
<li><a href="zlib.html" class="nav-zlib">Zlib</a></li>
</ul>
<hr class="line"/>

<ul>
<li><a href="https://github.com/nodejs/node" class="nav-https-github-com-nodejs-node">Code repository and issue tracker</a></li>
</ul>

    </div>

    <div id="column1" data-id="process" class="interior">
      <header class="header">
        <div class="header-container">
          <h1>Node.js v18.19.1 documentation</h1>
          <button class="theme-toggle-btn" id="theme-toggle-btn" title="Toggle dark mode/light mode" aria-label="Toggle dark mode/light mode" hidden>
            <svg xmlns="http://www.w3.org/2000/svg" class="icon dark-icon" height="24" width="24">
              <path fill="none" d="M0 0h24v24H0z" />
              <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"/>
              <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"/>
            </svg>
            <svg xmlns="http://www.w3.org/2000/svg" class="icon light-icon" height="24" width="24">
              <path d="M0 0h24v24H0z" fill="none" />
              <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"/>
            </svg>
          </button>
        </div>
        <div id="gtoc">
          <ul>
            <li class="pinned-header">Node.js v18.19.1</li>
            
    <li class="picker-header">
      <a href="#">
        <span class="collapsed-arrow">&#x25ba;</span><span class="expanded-arrow">&#x25bc;</span>
        Table of contents
      </a>

      <div class="picker"><div class="toc"><ul>
<li><a href="#process">Process</a><ul>
<li><a href="#process-events">Process events</a><ul>
<li><a href="#event-beforeexit">Event: <code>&#39;beforeExit&#39;</code></a></li>
<li><a href="#event-disconnect">Event: <code>&#39;disconnect&#39;</code></a></li>
<li><a href="#event-exit">Event: <code>&#39;exit&#39;</code></a></li>
<li><a href="#event-message">Event: <code>&#39;message&#39;</code></a></li>
<li><a href="#event-multipleresolves">Event: <code>&#39;multipleResolves&#39;</code></a></li>
<li><a href="#event-rejectionhandled">Event: <code>&#39;rejectionHandled&#39;</code></a></li>
<li><a href="#event-uncaughtexception">Event: <code>&#39;uncaughtException&#39;</code></a><ul>
<li><a href="#warning-using-uncaughtexception-correctly">Warning: Using <code>&#39;uncaughtException&#39;</code> correctly</a></li>
</ul>
</li>
<li><a href="#event-uncaughtexceptionmonitor">Event: <code>&#39;uncaughtExceptionMonitor&#39;</code></a></li>
<li><a href="#event-unhandledrejection">Event: <code>&#39;unhandledRejection&#39;</code></a></li>
<li><a href="#event-warning">Event: <code>&#39;warning&#39;</code></a></li>
<li><a href="#event-worker">Event: <code>&#39;worker&#39;</code></a><ul>
<li><a href="#emitting-custom-warnings">Emitting custom warnings</a></li>
<li><a href="#nodejs-warning-names">Node.js warning names</a></li>
</ul>
</li>
<li><a href="#signal-events">Signal events</a></li>
</ul>
</li>
<li><a href="#processabort"><code>process.abort()</code></a></li>
<li><a href="#processallowednodeenvironmentflags"><code>process.allowedNodeEnvironmentFlags</code></a></li>
<li><a href="#processarch"><code>process.arch</code></a></li>
<li><a href="#processargv"><code>process.argv</code></a></li>
<li><a href="#processargv0"><code>process.argv0</code></a></li>
<li><a href="#processchannel"><code>process.channel</code></a><ul>
<li><a href="#processchannelref"><code>process.channel.ref()</code></a></li>
<li><a href="#processchannelunref"><code>process.channel.unref()</code></a></li>
</ul>
</li>
<li><a href="#processchdirdirectory"><code>process.chdir(directory)</code></a></li>
<li><a href="#processconfig"><code>process.config</code></a></li>
<li><a href="#processconnected"><code>process.connected</code></a></li>
<li><a href="#processconstrainedmemory"><code>process.constrainedMemory()</code></a></li>
<li><a href="#processcpuusagepreviousvalue"><code>process.cpuUsage([previousValue])</code></a></li>
<li><a href="#processcwd"><code>process.cwd()</code></a></li>
<li><a href="#processdebugport"><code>process.debugPort</code></a></li>
<li><a href="#processdisconnect"><code>process.disconnect()</code></a></li>
<li><a href="#processdlopenmodule-filename-flags"><code>process.dlopen(module, filename[, flags])</code></a></li>
<li><a href="#processemitwarningwarning-options"><code>process.emitWarning(warning[, options])</code></a></li>
<li><a href="#processemitwarningwarning-type-code-ctor"><code>process.emitWarning(warning[, type[, code]][, ctor])</code></a><ul>
<li><a href="#avoiding-duplicate-warnings">Avoiding duplicate warnings</a></li>
</ul>
</li>
<li><a href="#processenv"><code>process.env</code></a></li>
<li><a href="#processexecargv"><code>process.execArgv</code></a></li>
<li><a href="#processexecpath"><code>process.execPath</code></a></li>
<li><a href="#processexitcode"><code>process.exit([code])</code></a></li>
<li><a href="#processexitcode_1"><code>process.exitCode</code></a></li>
<li><a href="#processgetactiveresourcesinfo"><code>process.getActiveResourcesInfo()</code></a></li>
<li><a href="#processgetegid"><code>process.getegid()</code></a></li>
<li><a href="#processgeteuid"><code>process.geteuid()</code></a></li>
<li><a href="#processgetgid"><code>process.getgid()</code></a></li>
<li><a href="#processgetgroups"><code>process.getgroups()</code></a></li>
<li><a href="#processgetuid"><code>process.getuid()</code></a></li>
<li><a href="#processhasuncaughtexceptioncapturecallback"><code>process.hasUncaughtExceptionCaptureCallback()</code></a></li>
<li><a href="#processhrtimetime"><code>process.hrtime([time])</code></a></li>
<li><a href="#processhrtimebigint"><code>process.hrtime.bigint()</code></a></li>
<li><a href="#processinitgroupsuser-extragroup"><code>process.initgroups(user, extraGroup)</code></a></li>
<li><a href="#processkillpid-signal"><code>process.kill(pid[, signal])</code></a></li>
<li><a href="#processmainmodule"><code>process.mainModule</code></a></li>
<li><a href="#processmemoryusage"><code>process.memoryUsage()</code></a></li>
<li><a href="#processmemoryusagerss"><code>process.memoryUsage.rss()</code></a></li>
<li><a href="#processnexttickcallback-args"><code>process.nextTick(callback[, ...args])</code></a><ul>
<li><a href="#when-to-use-queuemicrotask-vs-processnexttick">When to use <code>queueMicrotask()</code> vs. <code>process.nextTick()</code></a></li>
</ul>
</li>
<li><a href="#processnodeprecation"><code>process.noDeprecation</code></a></li>
<li><a href="#processpid"><code>process.pid</code></a></li>
<li><a href="#processplatform"><code>process.platform</code></a></li>
<li><a href="#processppid"><code>process.ppid</code></a></li>
<li><a href="#processrelease"><code>process.release</code></a></li>
<li><a href="#processreport"><code>process.report</code></a><ul>
<li><a href="#processreportcompact"><code>process.report.compact</code></a></li>
<li><a href="#processreportdirectory"><code>process.report.directory</code></a></li>
<li><a href="#processreportfilename"><code>process.report.filename</code></a></li>
<li><a href="#processreportgetreporterr"><code>process.report.getReport([err])</code></a></li>
<li><a href="#processreportreportonfatalerror"><code>process.report.reportOnFatalError</code></a></li>
<li><a href="#processreportreportonsignal"><code>process.report.reportOnSignal</code></a></li>
<li><a href="#processreportreportonuncaughtexception"><code>process.report.reportOnUncaughtException</code></a></li>
<li><a href="#processreportsignal"><code>process.report.signal</code></a></li>
<li><a href="#processreportwritereportfilename-err"><code>process.report.writeReport([filename][, err])</code></a></li>
</ul>
</li>
<li><a href="#processresourceusage"><code>process.resourceUsage()</code></a></li>
<li><a href="#processsendmessage-sendhandle-options-callback"><code>process.send(message[, sendHandle[, options]][, callback])</code></a></li>
<li><a href="#processsetegidid"><code>process.setegid(id)</code></a></li>
<li><a href="#processseteuidid"><code>process.seteuid(id)</code></a></li>
<li><a href="#processsetgidid"><code>process.setgid(id)</code></a></li>
<li><a href="#processsetgroupsgroups"><code>process.setgroups(groups)</code></a></li>
<li><a href="#processsetuidid"><code>process.setuid(id)</code></a></li>
<li><a href="#processsetsourcemapsenabledval"><code>process.setSourceMapsEnabled(val)</code></a></li>
<li><a href="#processsetuncaughtexceptioncapturecallbackfn"><code>process.setUncaughtExceptionCaptureCallback(fn)</code></a></li>
<li><a href="#processsourcemapsenabled"><code>process.sourceMapsEnabled</code></a></li>
<li><a href="#processstderr"><code>process.stderr</code></a><ul>
<li><a href="#processstderrfd"><code>process.stderr.fd</code></a></li>
</ul>
</li>
<li><a href="#processstdin"><code>process.stdin</code></a><ul>
<li><a href="#processstdinfd"><code>process.stdin.fd</code></a></li>
</ul>
</li>
<li><a href="#processstdout"><code>process.stdout</code></a><ul>
<li><a href="#processstdoutfd"><code>process.stdout.fd</code></a></li>
<li><a href="#a-note-on-process-io">A note on process I/O</a></li>
</ul>
</li>
<li><a href="#processthrowdeprecation"><code>process.throwDeprecation</code></a></li>
<li><a href="#processtitle"><code>process.title</code></a></li>
<li><a href="#processtracedeprecation"><code>process.traceDeprecation</code></a></li>
<li><a href="#processumask"><code>process.umask()</code></a></li>
<li><a href="#processumaskmask"><code>process.umask(mask)</code></a></li>
<li><a href="#processuptime"><code>process.uptime()</code></a></li>
<li><a href="#processversion"><code>process.version</code></a></li>
<li><a href="#processversions"><code>process.versions</code></a></li>
<li><a href="#exit-codes">Exit codes</a></li>
</ul>
</li>
</ul>
</div></div>
    </li>
  
            
    <li class="picker-header">
      <a href="#">
        <span class="collapsed-arrow">&#x25ba;</span><span class="expanded-arrow">&#x25bc;</span>
        Index
      </a>

      <div class="picker"><ul>
<li><a href="documentation.html" class="nav-documentation">About this documentation</a></li>
<li><a href="synopsis.html" class="nav-synopsis">Usage and example</a></li>

      <li>
        <a href="index.html">Index</a>
      </li>
    </ul>
  
<hr class="line"/>

<ul>
<li><a href="assert.html" class="nav-assert">Assertion testing</a></li>
<li><a href="async_context.html" class="nav-async_context">Asynchronous context tracking</a></li>
<li><a href="async_hooks.html" class="nav-async_hooks">Async hooks</a></li>
<li><a href="buffer.html" class="nav-buffer">Buffer</a></li>
<li><a href="addons.html" class="nav-addons">C++ addons</a></li>
<li><a href="n-api.html" class="nav-n-api">C/C++ addons with Node-API</a></li>
<li><a href="embedding.html" class="nav-embedding">C++ embedder API</a></li>
<li><a href="child_process.html" class="nav-child_process">Child processes</a></li>
<li><a href="cluster.html" class="nav-cluster">Cluster</a></li>
<li><a href="cli.html" class="nav-cli">Command-line options</a></li>
<li><a href="console.html" class="nav-console">Console</a></li>
<li><a href="corepack.html" class="nav-corepack">Corepack</a></li>
<li><a href="crypto.html" class="nav-crypto">Crypto</a></li>
<li><a href="debugger.html" class="nav-debugger">Debugger</a></li>
<li><a href="deprecations.html" class="nav-deprecations">Deprecated APIs</a></li>
<li><a href="diagnostics_channel.html" class="nav-diagnostics_channel">Diagnostics Channel</a></li>
<li><a href="dns.html" class="nav-dns">DNS</a></li>
<li><a href="domain.html" class="nav-domain">Domain</a></li>
<li><a href="errors.html" class="nav-errors">Errors</a></li>
<li><a href="events.html" class="nav-events">Events</a></li>
<li><a href="fs.html" class="nav-fs">File system</a></li>
<li><a href="globals.html" class="nav-globals">Globals</a></li>
<li><a href="http.html" class="nav-http">HTTP</a></li>
<li><a href="http2.html" class="nav-http2">HTTP/2</a></li>
<li><a href="https.html" class="nav-https">HTTPS</a></li>
<li><a href="inspector.html" class="nav-inspector">Inspector</a></li>
<li><a href="intl.html" class="nav-intl">Internationalization</a></li>
<li><a href="modules.html" class="nav-modules">Modules: CommonJS modules</a></li>
<li><a href="esm.html" class="nav-esm">Modules: ECMAScript modules</a></li>
<li><a href="module.html" class="nav-module">Modules: <code>node:module</code> API</a></li>
<li><a href="packages.html" class="nav-packages">Modules: Packages</a></li>
<li><a href="net.html" class="nav-net">Net</a></li>
<li><a href="os.html" class="nav-os">OS</a></li>
<li><a href="path.html" class="nav-path">Path</a></li>
<li><a href="perf_hooks.html" class="nav-perf_hooks">Performance hooks</a></li>
<li><a href="permissions.html" class="nav-permissions">Permissions</a></li>
<li><a href="process.html" class="nav-process active">Process</a></li>
<li><a href="punycode.html" class="nav-punycode">Punycode</a></li>
<li><a href="querystring.html" class="nav-querystring">Query strings</a></li>
<li><a href="readline.html" class="nav-readline">Readline</a></li>
<li><a href="repl.html" class="nav-repl">REPL</a></li>
<li><a href="report.html" class="nav-report">Report</a></li>
<li><a href="single-executable-applications.html" class="nav-single-executable-applications">Single executable applications</a></li>
<li><a href="stream.html" class="nav-stream">Stream</a></li>
<li><a href="string_decoder.html" class="nav-string_decoder">String decoder</a></li>
<li><a href="test.html" class="nav-test">Test runner</a></li>
<li><a href="timers.html" class="nav-timers">Timers</a></li>
<li><a href="tls.html" class="nav-tls">TLS/SSL</a></li>
<li><a href="tracing.html" class="nav-tracing">Trace events</a></li>
<li><a href="tty.html" class="nav-tty">TTY</a></li>
<li><a href="dgram.html" class="nav-dgram">UDP/datagram</a></li>
<li><a href="url.html" class="nav-url">URL</a></li>
<li><a href="util.html" class="nav-util">Utilities</a></li>
<li><a href="v8.html" class="nav-v8">V8</a></li>
<li><a href="vm.html" class="nav-vm">VM</a></li>
<li><a href="wasi.html" class="nav-wasi">WASI</a></li>
<li><a href="webcrypto.html" class="nav-webcrypto">Web Crypto API</a></li>
<li><a href="webstreams.html" class="nav-webstreams">Web Streams API</a></li>
<li><a href="worker_threads.html" class="nav-worker_threads">Worker threads</a></li>
<li><a href="zlib.html" class="nav-zlib">Zlib</a></li>
</ul>
<hr class="line"/>

<ul>
<li><a href="https://github.com/nodejs/node" class="nav-https-github-com-nodejs-node">Code repository and issue tracker</a></li>
</ul>
</div>
    </li>
  
            
    <li class="picker-header">
      <a href="#">
        <span class="collapsed-arrow">&#x25ba;</span><span class="expanded-arrow">&#x25bc;</span>
        Other versions
      </a>
      <div class="picker"><ol id="alt-docs"><li><a href="https://nodejs.org/docs/latest-v18.x/api/process.html">18.x <b>LTS</b></a></li>
<li><a href="https://nodejs.org/docs/latest-v17.x/api/process.html">17.x</a></li>
<li><a href="https://nodejs.org/docs/latest-v16.x/api/process.html">16.x <b>LTS</b></a></li>
<li><a href="https://nodejs.org/docs/latest-v15.x/api/process.html">15.x</a></li>
<li><a href="https://nodejs.org/docs/latest-v14.x/api/process.html">14.x</a></li>
<li><a href="https://nodejs.org/docs/latest-v13.x/api/process.html">13.x</a></li>
<li><a href="https://nodejs.org/docs/latest-v12.x/api/process.html">12.x</a></li>
<li><a href="https://nodejs.org/docs/latest-v11.x/api/process.html">11.x</a></li>
<li><a href="https://nodejs.org/docs/latest-v10.x/api/process.html">10.x</a></li>
<li><a href="https://nodejs.org/docs/latest-v9.x/api/process.html">9.x</a></li>
<li><a href="https://nodejs.org/docs/latest-v8.x/api/process.html">8.x</a></li>
<li><a href="https://nodejs.org/docs/latest-v7.x/api/process.html">7.x</a></li>
<li><a href="https://nodejs.org/docs/latest-v6.x/api/process.html">6.x</a></li>
<li><a href="https://nodejs.org/docs/latest-v5.x/api/process.html">5.x</a></li>
<li><a href="https://nodejs.org/docs/latest-v4.x/api/process.html">4.x</a></li>
<li><a href="https://nodejs.org/docs/latest-v0.12.x/api/process.html">0.12.x</a></li>
<li><a href="https://nodejs.org/docs/latest-v0.10.x/api/process.html">0.10.x</a></li></ol></div>
    </li>
  
            <li class="picker-header">
              <a href="#">
                <span class="collapsed-arrow">&#x25ba;</span><span class="expanded-arrow">&#x25bc;</span>
                Options
              </a>
        
              <div class="picker">
                <ul>
                  <li>
                    <a href="all.html">View on single page</a>
                  </li>
                  <li>
                    <a href="process.json">View as JSON</a>
                  </li>
                  <li class="edit_on_github"><a href="https://github.com/nodejs/node/edit/master/doc/api/process.md">Edit on GitHub</a></li>    
                </ul>
              </div>
            </li>
          </ul>
        </div>
        <hr>
      </header>

      <details id="toc" open><summary>Table of contents</summary><ul>
<li><a href="#process">Process</a><ul>
<li><a href="#process-events">Process events</a><ul>
<li><a href="#event-beforeexit">Event: <code>&#39;beforeExit&#39;</code></a></li>
<li><a href="#event-disconnect">Event: <code>&#39;disconnect&#39;</code></a></li>
<li><a href="#event-exit">Event: <code>&#39;exit&#39;</code></a></li>
<li><a href="#event-message">Event: <code>&#39;message&#39;</code></a></li>
<li><a href="#event-multipleresolves">Event: <code>&#39;multipleResolves&#39;</code></a></li>
<li><a href="#event-rejectionhandled">Event: <code>&#39;rejectionHandled&#39;</code></a></li>
<li><a href="#event-uncaughtexception">Event: <code>&#39;uncaughtException&#39;</code></a><ul>
<li><a href="#warning-using-uncaughtexception-correctly">Warning: Using <code>&#39;uncaughtException&#39;</code> correctly</a></li>
</ul>
</li>
<li><a href="#event-uncaughtexceptionmonitor">Event: <code>&#39;uncaughtExceptionMonitor&#39;</code></a></li>
<li><a href="#event-unhandledrejection">Event: <code>&#39;unhandledRejection&#39;</code></a></li>
<li><a href="#event-warning">Event: <code>&#39;warning&#39;</code></a></li>
<li><a href="#event-worker">Event: <code>&#39;worker&#39;</code></a><ul>
<li><a href="#emitting-custom-warnings">Emitting custom warnings</a></li>
<li><a href="#nodejs-warning-names">Node.js warning names</a></li>
</ul>
</li>
<li><a href="#signal-events">Signal events</a></li>
</ul>
</li>
<li><a href="#processabort"><code>process.abort()</code></a></li>
<li><a href="#processallowednodeenvironmentflags"><code>process.allowedNodeEnvironmentFlags</code></a></li>
<li><a href="#processarch"><code>process.arch</code></a></li>
<li><a href="#processargv"><code>process.argv</code></a></li>
<li><a href="#processargv0"><code>process.argv0</code></a></li>
<li><a href="#processchannel"><code>process.channel</code></a><ul>
<li><a href="#processchannelref"><code>process.channel.ref()</code></a></li>
<li><a href="#processchannelunref"><code>process.channel.unref()</code></a></li>
</ul>
</li>
<li><a href="#processchdirdirectory"><code>process.chdir(directory)</code></a></li>
<li><a href="#processconfig"><code>process.config</code></a></li>
<li><a href="#processconnected"><code>process.connected</code></a></li>
<li><a href="#processconstrainedmemory"><code>process.constrainedMemory()</code></a></li>
<li><a href="#processcpuusagepreviousvalue"><code>process.cpuUsage([previousValue])</code></a></li>
<li><a href="#processcwd"><code>process.cwd()</code></a></li>
<li><a href="#processdebugport"><code>process.debugPort</code></a></li>
<li><a href="#processdisconnect"><code>process.disconnect()</code></a></li>
<li><a href="#processdlopenmodule-filename-flags"><code>process.dlopen(module, filename[, flags])</code></a></li>
<li><a href="#processemitwarningwarning-options"><code>process.emitWarning(warning[, options])</code></a></li>
<li><a href="#processemitwarningwarning-type-code-ctor"><code>process.emitWarning(warning[, type[, code]][, ctor])</code></a><ul>
<li><a href="#avoiding-duplicate-warnings">Avoiding duplicate warnings</a></li>
</ul>
</li>
<li><a href="#processenv"><code>process.env</code></a></li>
<li><a href="#processexecargv"><code>process.execArgv</code></a></li>
<li><a href="#processexecpath"><code>process.execPath</code></a></li>
<li><a href="#processexitcode"><code>process.exit([code])</code></a></li>
<li><a href="#processexitcode_1"><code>process.exitCode</code></a></li>
<li><a href="#processgetactiveresourcesinfo"><code>process.getActiveResourcesInfo()</code></a></li>
<li><a href="#processgetegid"><code>process.getegid()</code></a></li>
<li><a href="#processgeteuid"><code>process.geteuid()</code></a></li>
<li><a href="#processgetgid"><code>process.getgid()</code></a></li>
<li><a href="#processgetgroups"><code>process.getgroups()</code></a></li>
<li><a href="#processgetuid"><code>process.getuid()</code></a></li>
<li><a href="#processhasuncaughtexceptioncapturecallback"><code>process.hasUncaughtExceptionCaptureCallback()</code></a></li>
<li><a href="#processhrtimetime"><code>process.hrtime([time])</code></a></li>
<li><a href="#processhrtimebigint"><code>process.hrtime.bigint()</code></a></li>
<li><a href="#processinitgroupsuser-extragroup"><code>process.initgroups(user, extraGroup)</code></a></li>
<li><a href="#processkillpid-signal"><code>process.kill(pid[, signal])</code></a></li>
<li><a href="#processmainmodule"><code>process.mainModule</code></a></li>
<li><a href="#processmemoryusage"><code>process.memoryUsage()</code></a></li>
<li><a href="#processmemoryusagerss"><code>process.memoryUsage.rss()</code></a></li>
<li><a href="#processnexttickcallback-args"><code>process.nextTick(callback[, ...args])</code></a><ul>
<li><a href="#when-to-use-queuemicrotask-vs-processnexttick">When to use <code>queueMicrotask()</code> vs. <code>process.nextTick()</code></a></li>
</ul>
</li>
<li><a href="#processnodeprecation"><code>process.noDeprecation</code></a></li>
<li><a href="#processpid"><code>process.pid</code></a></li>
<li><a href="#processplatform"><code>process.platform</code></a></li>
<li><a href="#processppid"><code>process.ppid</code></a></li>
<li><a href="#processrelease"><code>process.release</code></a></li>
<li><a href="#processreport"><code>process.report</code></a><ul>
<li><a href="#processreportcompact"><code>process.report.compact</code></a></li>
<li><a href="#processreportdirectory"><code>process.report.directory</code></a></li>
<li><a href="#processreportfilename"><code>process.report.filename</code></a></li>
<li><a href="#processreportgetreporterr"><code>process.report.getReport([err])</code></a></li>
<li><a href="#processreportreportonfatalerror"><code>process.report.reportOnFatalError</code></a></li>
<li><a href="#processreportreportonsignal"><code>process.report.reportOnSignal</code></a></li>
<li><a href="#processreportreportonuncaughtexception"><code>process.report.reportOnUncaughtException</code></a></li>
<li><a href="#processreportsignal"><code>process.report.signal</code></a></li>
<li><a href="#processreportwritereportfilename-err"><code>process.report.writeReport([filename][, err])</code></a></li>
</ul>
</li>
<li><a href="#processresourceusage"><code>process.resourceUsage()</code></a></li>
<li><a href="#processsendmessage-sendhandle-options-callback"><code>process.send(message[, sendHandle[, options]][, callback])</code></a></li>
<li><a href="#processsetegidid"><code>process.setegid(id)</code></a></li>
<li><a href="#processseteuidid"><code>process.seteuid(id)</code></a></li>
<li><a href="#processsetgidid"><code>process.setgid(id)</code></a></li>
<li><a href="#processsetgroupsgroups"><code>process.setgroups(groups)</code></a></li>
<li><a href="#processsetuidid"><code>process.setuid(id)</code></a></li>
<li><a href="#processsetsourcemapsenabledval"><code>process.setSourceMapsEnabled(val)</code></a></li>
<li><a href="#processsetuncaughtexceptioncapturecallbackfn"><code>process.setUncaughtExceptionCaptureCallback(fn)</code></a></li>
<li><a href="#processsourcemapsenabled"><code>process.sourceMapsEnabled</code></a></li>
<li><a href="#processstderr"><code>process.stderr</code></a><ul>
<li><a href="#processstderrfd"><code>process.stderr.fd</code></a></li>
</ul>
</li>
<li><a href="#processstdin"><code>process.stdin</code></a><ul>
<li><a href="#processstdinfd"><code>process.stdin.fd</code></a></li>
</ul>
</li>
<li><a href="#processstdout"><code>process.stdout</code></a><ul>
<li><a href="#processstdoutfd"><code>process.stdout.fd</code></a></li>
<li><a href="#a-note-on-process-io">A note on process I/O</a></li>
</ul>
</li>
<li><a href="#processthrowdeprecation"><code>process.throwDeprecation</code></a></li>
<li><a href="#processtitle"><code>process.title</code></a></li>
<li><a href="#processtracedeprecation"><code>process.traceDeprecation</code></a></li>
<li><a href="#processumask"><code>process.umask()</code></a></li>
<li><a href="#processumaskmask"><code>process.umask(mask)</code></a></li>
<li><a href="#processuptime"><code>process.uptime()</code></a></li>
<li><a href="#processversion"><code>process.version</code></a></li>
<li><a href="#processversions"><code>process.versions</code></a></li>
<li><a href="#exit-codes">Exit codes</a></li>
</ul>
</li>
</ul>
</details>

      <div id="apicontent">
        <h2>Process<span><a class="mark" href="#process" id="process">#</a></span><a aria-hidden="true" class="legacy" id="process_process"></a></h2>
<!-- introduced_in=v0.10.0 -->

<!-- type=global -->

<!-- source_link=lib/process.js -->

<p>The <code>process</code> object provides information about, and control over, the current
Node.js process.</p>
<pre><code class="language-mjs">import process from &#39;node:process&#39;;
</code></pre>
<pre><code class="language-cjs">const process = require(&#39;node:process&#39;);
</code></pre>
<section><h3>Process events<span><a class="mark" href="#process-events" id="process-events">#</a></span><a aria-hidden="true" class="legacy" id="process_process_events"></a></h3>
<p>The <code>process</code> object is an instance of <a href="events.html#class-eventemitter"><code>EventEmitter</code></a>.</p>
<h4>Event: <code>&#39;beforeExit&#39;</code><span><a class="mark" href="#event-beforeexit" id="event-beforeexit">#</a></span><a aria-hidden="true" class="legacy" id="process_event_beforeexit"></a></h4>
<div class="api_metadata">
<span>Added in: v0.11.12</span>
</div><p>The <code>&#39;beforeExit&#39;</code> event is emitted when Node.js empties its event loop and has
no additional work to schedule. Normally, the Node.js process will exit when
there is no work scheduled, but a listener registered on the <code>&#39;beforeExit&#39;</code>
event can make asynchronous calls, and thereby cause the Node.js process to
continue.</p>
<p>The listener callback function is invoked with the value of
<a href="#processexitcode_1"><code>process.exitCode</code></a> passed as the only argument.</p>
<p>The <code>&#39;beforeExit&#39;</code> event is <em>not</em> emitted for conditions causing explicit
termination, such as calling <a href="#processexitcode"><code>process.exit()</code></a> or uncaught exceptions.</p>
<p>The <code>&#39;beforeExit&#39;</code> should <em>not</em> be used as an alternative to the <code>&#39;exit&#39;</code> event
unless the intention is to schedule additional work.</p>
<pre><code class="language-mjs">import process from &#39;node:process&#39;;

process.on(&#39;beforeExit&#39;, (code) =&gt; {
  console.log(&#39;Process beforeExit event with code: &#39;, code);
});

process.on(&#39;exit&#39;, (code) =&gt; {
  console.log(&#39;Process exit event with code: &#39;, code);
});

console.log(&#39;This message is displayed first.&#39;);

// Prints:
// This message is displayed first.
// Process beforeExit event with code: 0
// Process exit event with code: 0
</code></pre>
<pre><code class="language-cjs">const process = require(&#39;node:process&#39;);

process.on(&#39;beforeExit&#39;, (code) =&gt; {
  console.log(&#39;Process beforeExit event with code: &#39;, code);
});

process.on(&#39;exit&#39;, (code) =&gt; {
  console.log(&#39;Process exit event with code: &#39;, code);
});

console.log(&#39;This message is displayed first.&#39;);

// Prints:
// This message is displayed first.
// Process beforeExit event with code: 0
// Process exit event with code: 0
</code></pre>
<h4>Event: <code>&#39;disconnect&#39;</code><span><a class="mark" href="#event-disconnect" id="event-disconnect">#</a></span><a aria-hidden="true" class="legacy" id="process_event_disconnect"></a></h4>
<div class="api_metadata">
<span>Added in: v0.7.7</span>
</div><p>If the Node.js process is spawned with an IPC channel (see the <a href="child_process.html">Child Process</a>
and <a href="cluster.html">Cluster</a> documentation), the <code>&#39;disconnect&#39;</code> event will be emitted when
the IPC channel is closed.</p>
<h4>Event: <code>&#39;exit&#39;</code><span><a class="mark" href="#event-exit" id="event-exit">#</a></span><a aria-hidden="true" class="legacy" id="process_event_exit"></a></h4>
<div class="api_metadata">
<span>Added in: v0.1.7</span>
</div><ul>
<li><code>code</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer&gt;</a></li>
</ul>
<p>The <code>&#39;exit&#39;</code> event is emitted when the Node.js process is about to exit as a
result of either:</p>
<ul>
<li>The <code>process.exit()</code> method being called explicitly;</li>
<li>The Node.js event loop no longer having any additional work to perform.</li>
</ul>
<p>There is no way to prevent the exiting of the event loop at this point, and once
all <code>&#39;exit&#39;</code> listeners have finished running the Node.js process will terminate.</p>
<p>The listener callback function is invoked with the exit code specified either
by the <a href="#processexitcode_1"><code>process.exitCode</code></a> property, or the <code>exitCode</code> argument passed to the
<a href="#processexitcode"><code>process.exit()</code></a> method.</p>
<pre><code class="language-mjs">import process from &#39;node:process&#39;;

process.on(&#39;exit&#39;, (code) =&gt; {
  console.log(`About to exit with code: ${code}`);
});
</code></pre>
<pre><code class="language-cjs">const process = require(&#39;node:process&#39;);

process.on(&#39;exit&#39;, (code) =&gt; {
  console.log(`About to exit with code: ${code}`);
});
</code></pre>
<p>Listener functions <strong>must</strong> only perform <strong>synchronous</strong> operations. The Node.js
process will exit immediately after calling the <code>&#39;exit&#39;</code> event listeners
causing any additional work still queued in the event loop to be abandoned.
In the following example, for instance, the timeout will never occur:</p>
<pre><code class="language-mjs">import process from &#39;node:process&#39;;

process.on(&#39;exit&#39;, (code) =&gt; {
  setTimeout(() =&gt; {
    console.log(&#39;This will not run&#39;);
  }, 0);
});
</code></pre>
<pre><code class="language-cjs">const process = require(&#39;node:process&#39;);

process.on(&#39;exit&#39;, (code) =&gt; {
  setTimeout(() =&gt; {
    console.log(&#39;This will not run&#39;);
  }, 0);
});
</code></pre>
<h4>Event: <code>&#39;message&#39;</code><span><a class="mark" href="#event-message" id="event-message">#</a></span><a aria-hidden="true" class="legacy" id="process_event_message"></a></h4>
<div class="api_metadata">
<span>Added in: v0.5.10</span>
</div><ul>
<li><code>message</code> { Object | boolean | number | string | null } a parsed JSON object
or a serializable primitive value.</li>
<li><code>sendHandle</code> {net.Server|net.Socket} a <a href="net.html#class-netserver"><code>net.Server</code></a> or <a href="net.html#class-netsocket"><code>net.Socket</code></a>
object, or undefined.</li>
</ul>
<p>If the Node.js process is spawned with an IPC channel (see the <a href="child_process.html">Child Process</a>
and <a href="cluster.html">Cluster</a> documentation), the <code>&#39;message&#39;</code> event is emitted whenever a
message sent by a parent process using <a href="child_process.html#subprocesssendmessage-sendhandle-options-callback"><code>childprocess.send()</code></a> is received by
the child process.</p>
<p>The message goes through serialization and parsing. The resulting message might
not be the same as what is originally sent.</p>
<p>If the <code>serialization</code> option was set to <code>advanced</code> used when spawning the
process, the <code>message</code> argument can contain data that JSON is not able
to represent.
See <a href="child_process.html#advanced-serialization">Advanced serialization for <code>child_process</code></a> for more details.</p>
<h4>Event: <code>&#39;multipleResolves&#39;</code><span><a class="mark" href="#event-multipleresolves" id="event-multipleresolves">#</a></span><a aria-hidden="true" class="legacy" id="process_event_multipleresolves"></a></h4>
<div class="api_metadata">
<span>Added in: v10.12.0</span><span>Deprecated since: v17.6.0</span>
</div><blockquote>
<p>Stability: 0 - Deprecated</p>
</blockquote>
<ul>
<li><code>type</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> The resolution type. One of <code>&#39;resolve&#39;</code> or <code>&#39;reject&#39;</code>.</li>
<li><code>promise</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise" class="type">&lt;Promise&gt;</a> The promise that resolved or rejected more than once.</li>
<li><code>value</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types" class="type">&lt;any&gt;</a> The value with which the promise was either resolved or
rejected after the original resolve.</li>
</ul>
<p>The <code>&#39;multipleResolves&#39;</code> event is emitted whenever a <code>Promise</code> has been either:</p>
<ul>
<li>Resolved more than once.</li>
<li>Rejected more than once.</li>
<li>Rejected after resolve.</li>
<li>Resolved after reject.</li>
</ul>
<p>This is useful for tracking potential errors in an application while using the
<code>Promise</code> constructor, as multiple resolutions are silently swallowed. However,
the occurrence of this event does not necessarily indicate an error. For
example, <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race"><code>Promise.race()</code></a> can trigger a <code>&#39;multipleResolves&#39;</code> event.</p>
<p>Because of the unreliability of the event in cases like the
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race"><code>Promise.race()</code></a> example above it has been deprecated.</p>
<pre><code class="language-mjs">import process from &#39;node:process&#39;;

process.on(&#39;multipleResolves&#39;, (type, promise, reason) =&gt; {
  console.error(type, promise, reason);
  setImmediate(() =&gt; process.exit(1));
});

async function main() {
  try {
    return await new Promise((resolve, reject) =&gt; {
      resolve(&#39;First call&#39;);
      resolve(&#39;Swallowed resolve&#39;);
      reject(new Error(&#39;Swallowed reject&#39;));
    });
  } catch {
    throw new Error(&#39;Failed&#39;);
  }
}

main().then(console.log);
// resolve: Promise { &#39;First call&#39; } &#39;Swallowed resolve&#39;
// reject: Promise { &#39;First call&#39; } Error: Swallowed reject
//     at Promise (*)
//     at new Promise (&lt;anonymous&gt;)
//     at main (*)
// First call
</code></pre>
<pre><code class="language-cjs">const process = require(&#39;node:process&#39;);

process.on(&#39;multipleResolves&#39;, (type, promise, reason) =&gt; {
  console.error(type, promise, reason);
  setImmediate(() =&gt; process.exit(1));
});

async function main() {
  try {
    return await new Promise((resolve, reject) =&gt; {
      resolve(&#39;First call&#39;);
      resolve(&#39;Swallowed resolve&#39;);
      reject(new Error(&#39;Swallowed reject&#39;));
    });
  } catch {
    throw new Error(&#39;Failed&#39;);
  }
}

main().then(console.log);
// resolve: Promise { &#39;First call&#39; } &#39;Swallowed resolve&#39;
// reject: Promise { &#39;First call&#39; } Error: Swallowed reject
//     at Promise (*)
//     at new Promise (&lt;anonymous&gt;)
//     at main (*)
// First call
</code></pre>
<h4>Event: <code>&#39;rejectionHandled&#39;</code><span><a class="mark" href="#event-rejectionhandled" id="event-rejectionhandled">#</a></span><a aria-hidden="true" class="legacy" id="process_event_rejectionhandled"></a></h4>
<div class="api_metadata">
<span>Added in: v1.4.1</span>
</div><ul>
<li><code>promise</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise" class="type">&lt;Promise&gt;</a> The late handled promise.</li>
</ul>
<p>The <code>&#39;rejectionHandled&#39;</code> event is emitted whenever a <code>Promise</code> has been rejected
and an error handler was attached to it (using <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch"><code>promise.catch()</code></a>, for
example) later than one turn of the Node.js event loop.</p>
<p>The <code>Promise</code> object would have previously been emitted in an
<code>&#39;unhandledRejection&#39;</code> event, but during the course of processing gained a
rejection handler.</p>
<p>There is no notion of a top level for a <code>Promise</code> chain at which rejections can
always be handled. Being inherently asynchronous in nature, a <code>Promise</code>
rejection can be handled at a future point in time, possibly much later than
the event loop turn it takes for the <code>&#39;unhandledRejection&#39;</code> event to be emitted.</p>
<p>Another way of stating this is that, unlike in synchronous code where there is
an ever-growing list of unhandled exceptions, with Promises there can be a
growing-and-shrinking list of unhandled rejections.</p>
<p>In synchronous code, the <code>&#39;uncaughtException&#39;</code> event is emitted when the list of
unhandled exceptions grows.</p>
<p>In asynchronous code, the <code>&#39;unhandledRejection&#39;</code> event is emitted when the list
of unhandled rejections grows, and the <code>&#39;rejectionHandled&#39;</code> event is emitted
when the list of unhandled rejections shrinks.</p>
<pre><code class="language-mjs">import process from &#39;node:process&#39;;

const unhandledRejections = new Map();
process.on(&#39;unhandledRejection&#39;, (reason, promise) =&gt; {
  unhandledRejections.set(promise, reason);
});
process.on(&#39;rejectionHandled&#39;, (promise) =&gt; {
  unhandledRejections.delete(promise);
});
</code></pre>
<pre><code class="language-cjs">const process = require(&#39;node:process&#39;);

const unhandledRejections = new Map();
process.on(&#39;unhandledRejection&#39;, (reason, promise) =&gt; {
  unhandledRejections.set(promise, reason);
});
process.on(&#39;rejectionHandled&#39;, (promise) =&gt; {
  unhandledRejections.delete(promise);
});
</code></pre>
<p>In this example, the <code>unhandledRejections</code> <code>Map</code> will grow and shrink over time,
reflecting rejections that start unhandled and then become handled. It is
possible to record such errors in an error log, either periodically (which is
likely best for long-running application) or upon process exit (which is likely
most convenient for scripts).</p>
<h4>Event: <code>&#39;uncaughtException&#39;</code><span><a class="mark" href="#event-uncaughtexception" id="event-uncaughtexception">#</a></span><a aria-hidden="true" class="legacy" id="process_event_uncaughtexception"></a></h4>
<div class="api_metadata">
<details class="changelog"><summary>History</summary>
<table>
<tr><th>Version</th><th>Changes</th></tr>
<tr><td>v12.0.0, v10.17.0</td>
<td><p>Added the <code>origin</code> argument.</p>
</td></tr>
<tr><td>v0.1.18</td>
<td><p><span>Added in: v0.1.18</span></p>
</td></tr>
</table>
</details>
</div><ul>
<li><code>err</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error" class="type">&lt;Error&gt;</a> The uncaught exception.</li>
<li><code>origin</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> Indicates if the exception originates from an unhandled
rejection or from a synchronous error. Can either be <code>&#39;uncaughtException&#39;</code> or
<code>&#39;unhandledRejection&#39;</code>. The latter is used when an exception happens in a
<code>Promise</code> based async context (or if a <code>Promise</code> is rejected) and
<a href="cli.html#--unhandled-rejectionsmode"><code>--unhandled-rejections</code></a> flag set to <code>strict</code> or <code>throw</code> (which is the
default) and the rejection is not handled, or when a rejection happens during
the command line entry point&#39;s ES module static loading phase.</li>
</ul>
<p>The <code>&#39;uncaughtException&#39;</code> event is emitted when an uncaught JavaScript
exception bubbles all the way back to the event loop. By default, Node.js
handles such exceptions by printing the stack trace to <code>stderr</code> and exiting
with code 1, overriding any previously set <a href="#processexitcode_1"><code>process.exitCode</code></a>.
Adding a handler for the <code>&#39;uncaughtException&#39;</code> event overrides this default
behavior. Alternatively, change the <a href="#processexitcode_1"><code>process.exitCode</code></a> in the
<code>&#39;uncaughtException&#39;</code> handler which will result in the process exiting with the
provided exit code. Otherwise, in the presence of such handler the process will
exit with 0.</p>
<pre><code class="language-mjs">import process from &#39;node:process&#39;;

process.on(&#39;uncaughtException&#39;, (err, origin) =&gt; {
  fs.writeSync(
    process.stderr.fd,
    `Caught exception: ${err}\n` +
    `Exception origin: ${origin}`,
  );
});

setTimeout(() =&gt; {
  console.log(&#39;This will still run.&#39;);
}, 500);

// Intentionally cause an exception, but don&#39;t catch it.
nonexistentFunc();
console.log(&#39;This will not run.&#39;);
</code></pre>
<pre><code class="language-cjs">const process = require(&#39;node:process&#39;);

process.on(&#39;uncaughtException&#39;, (err, origin) =&gt; {
  fs.writeSync(
    process.stderr.fd,
    `Caught exception: ${err}\n` +
    `Exception origin: ${origin}`,
  );
});

setTimeout(() =&gt; {
  console.log(&#39;This will still run.&#39;);
}, 500);

// Intentionally cause an exception, but don&#39;t catch it.
nonexistentFunc();
console.log(&#39;This will not run.&#39;);
</code></pre>
<p>It is possible to monitor <code>&#39;uncaughtException&#39;</code> events without overriding the
default behavior to exit the process by installing a
<code>&#39;uncaughtExceptionMonitor&#39;</code> listener.</p>
<h5>Warning: Using <code>&#39;uncaughtException&#39;</code> correctly<span><a class="mark" href="#warning-using-uncaughtexception-correctly" id="warning-using-uncaughtexception-correctly">#</a></span><a aria-hidden="true" class="legacy" id="process_warning_using_uncaughtexception_correctly"></a></h5>
<p><code>&#39;uncaughtException&#39;</code> is a crude mechanism for exception handling
intended to be used only as a last resort. The event <em>should not</em> be used as
an equivalent to <code>On Error Resume Next</code>. Unhandled exceptions inherently mean
that an application is in an undefined state. Attempting to resume application
code without properly recovering from the exception can cause additional
unforeseen and unpredictable issues.</p>
<p>Exceptions thrown from within the event handler will not be caught. Instead the
process will exit with a non-zero exit code and the stack trace will be printed.
This is to avoid infinite recursion.</p>
<p>Attempting to resume normally after an uncaught exception can be similar to
pulling out the power cord when upgrading a computer. Nine out of ten
times, nothing happens. But the tenth time, the system becomes corrupted.</p>
<p>The correct use of <code>&#39;uncaughtException&#39;</code> is to perform synchronous cleanup
of allocated resources (e.g. file descriptors, handles, etc) before shutting
down the process. <strong>It is not safe to resume normal operation after
<code>&#39;uncaughtException&#39;</code>.</strong></p>
<p>To restart a crashed application in a more reliable way, whether
<code>&#39;uncaughtException&#39;</code> is emitted or not, an external monitor should be employed
in a separate process to detect application failures and recover or restart as
needed.</p>
<h4>Event: <code>&#39;uncaughtExceptionMonitor&#39;</code><span><a class="mark" href="#event-uncaughtexceptionmonitor" id="event-uncaughtexceptionmonitor">#</a></span><a aria-hidden="true" class="legacy" id="process_event_uncaughtexceptionmonitor"></a></h4>
<div class="api_metadata">
<span>Added in: v13.7.0, v12.17.0</span>
</div><ul>
<li><code>err</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error" class="type">&lt;Error&gt;</a> The uncaught exception.</li>
<li><code>origin</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> Indicates if the exception originates from an unhandled
rejection or from synchronous errors. Can either be <code>&#39;uncaughtException&#39;</code> or
<code>&#39;unhandledRejection&#39;</code>. The latter is used when an exception happens in a
<code>Promise</code> based async context (or if a <code>Promise</code> is rejected) and
<a href="cli.html#--unhandled-rejectionsmode"><code>--unhandled-rejections</code></a> flag set to <code>strict</code> or <code>throw</code> (which is the
default) and the rejection is not handled, or when a rejection happens during
the command line entry point&#39;s ES module static loading phase.</li>
</ul>
<p>The <code>&#39;uncaughtExceptionMonitor&#39;</code> event is emitted before an
<code>&#39;uncaughtException&#39;</code> event is emitted or a hook installed via
<a href="#processsetuncaughtexceptioncapturecallbackfn"><code>process.setUncaughtExceptionCaptureCallback()</code></a> is called.</p>
<p>Installing an <code>&#39;uncaughtExceptionMonitor&#39;</code> listener does not change the behavior
once an <code>&#39;uncaughtException&#39;</code> event is emitted. The process will
still crash if no <code>&#39;uncaughtException&#39;</code> listener is installed.</p>
<pre><code class="language-mjs">import process from &#39;node:process&#39;;

process.on(&#39;uncaughtExceptionMonitor&#39;, (err, origin) =&gt; {
  MyMonitoringTool.logSync(err, origin);
});

// Intentionally cause an exception, but don&#39;t catch it.
nonexistentFunc();
// Still crashes Node.js
</code></pre>
<pre><code class="language-cjs">const process = require(&#39;node:process&#39;);

process.on(&#39;uncaughtExceptionMonitor&#39;, (err, origin) =&gt; {
  MyMonitoringTool.logSync(err, origin);
});

// Intentionally cause an exception, but don&#39;t catch it.
nonexistentFunc();
// Still crashes Node.js
</code></pre>
<h4>Event: <code>&#39;unhandledRejection&#39;</code><span><a class="mark" href="#event-unhandledrejection" id="event-unhandledrejection">#</a></span><a aria-hidden="true" class="legacy" id="process_event_unhandledrejection"></a></h4>
<div class="api_metadata">
<details class="changelog"><summary>History</summary>
<table>
<tr><th>Version</th><th>Changes</th></tr>
<tr><td>v7.0.0</td>
<td><p>Not handling <code>Promise</code> rejections is deprecated.</p>
</td></tr>
<tr><td>v6.6.0</td>
<td><p>Unhandled <code>Promise</code> rejections will now emit a process warning.</p>
</td></tr>
<tr><td>v1.4.1</td>
<td><p><span>Added in: v1.4.1</span></p>
</td></tr>
</table>
</details>
</div><ul>
<li><code>reason</code> {Error|any} The object with which the promise was rejected
(typically an <a href="errors.html#class-error"><code>Error</code></a> object).</li>
<li><code>promise</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise" class="type">&lt;Promise&gt;</a> The rejected promise.</li>
</ul>
<p>The <code>&#39;unhandledRejection&#39;</code> event is emitted whenever a <code>Promise</code> is rejected and
no error handler is attached to the promise within a turn of the event loop.
When programming with Promises, exceptions are encapsulated as &quot;rejected
promises&quot;. Rejections can be caught and handled using <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch"><code>promise.catch()</code></a> and
are propagated through a <code>Promise</code> chain. The <code>&#39;unhandledRejection&#39;</code> event is
useful for detecting and keeping track of promises that were rejected whose
rejections have not yet been handled.</p>
<pre><code class="language-mjs">import process from &#39;node:process&#39;;

process.on(&#39;unhandledRejection&#39;, (reason, promise) =&gt; {
  console.log(&#39;Unhandled Rejection at:&#39;, promise, &#39;reason:&#39;, reason);
  // Application specific logging, throwing an error, or other logic here
});

somePromise.then((res) =&gt; {
  return reportToUser(JSON.pasre(res)); // Note the typo (`pasre`)
}); // No `.catch()` or `.then()`
</code></pre>
<pre><code class="language-cjs">const process = require(&#39;node:process&#39;);

process.on(&#39;unhandledRejection&#39;, (reason, promise) =&gt; {
  console.log(&#39;Unhandled Rejection at:&#39;, promise, &#39;reason:&#39;, reason);
  // Application specific logging, throwing an error, or other logic here
});

somePromise.then((res) =&gt; {
  return reportToUser(JSON.pasre(res)); // Note the typo (`pasre`)
}); // No `.catch()` or `.then()`
</code></pre>
<p>The following will also trigger the <code>&#39;unhandledRejection&#39;</code> event to be
emitted:</p>
<pre><code class="language-mjs">import process from &#39;node:process&#39;;

function SomeResource() {
  // Initially set the loaded status to a rejected promise
  this.loaded = Promise.reject(new Error(&#39;Resource not yet loaded!&#39;));
}

const resource = new SomeResource();
// no .catch or .then on resource.loaded for at least a turn
</code></pre>
<pre><code class="language-cjs">const process = require(&#39;node:process&#39;);

function SomeResource() {
  // Initially set the loaded status to a rejected promise
  this.loaded = Promise.reject(new Error(&#39;Resource not yet loaded!&#39;));
}

const resource = new SomeResource();
// no .catch or .then on resource.loaded for at least a turn
</code></pre>
<p>In this example case, it is possible to track the rejection as a developer error
as would typically be the case for other <code>&#39;unhandledRejection&#39;</code> events. To
address such failures, a non-operational
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch"><code>.catch(() =&gt; { })</code></a> handler may be attached to
<code>resource.loaded</code>, which would prevent the <code>&#39;unhandledRejection&#39;</code> event from
being emitted.</p>
<h4>Event: <code>&#39;warning&#39;</code><span><a class="mark" href="#event-warning" id="event-warning">#</a></span><a aria-hidden="true" class="legacy" id="process_event_warning"></a></h4>
<div class="api_metadata">
<span>Added in: v6.0.0</span>
</div><ul>
<li><code>warning</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error" class="type">&lt;Error&gt;</a> Key properties of the warning are:<ul>
<li><code>name</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> The name of the warning. <strong>Default:</strong> <code>&#39;Warning&#39;</code>.</li>
<li><code>message</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> A system-provided description of the warning.</li>
<li><code>stack</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> A stack trace to the location in the code where the warning
was issued.</li>
</ul>
</li>
</ul>
<p>The <code>&#39;warning&#39;</code> event is emitted whenever Node.js emits a process warning.</p>
<p>A process warning is similar to an error in that it describes exceptional
conditions that are being brought to the user&#39;s attention. However, warnings
are not part of the normal Node.js and JavaScript error handling flow.
Node.js can emit warnings whenever it detects bad coding practices that could
lead to sub-optimal application performance, bugs, or security vulnerabilities.</p>
<pre><code class="language-mjs">import process from &#39;node:process&#39;;

process.on(&#39;warning&#39;, (warning) =&gt; {
  console.warn(warning.name);    // Print the warning name
  console.warn(warning.message); // Print the warning message
  console.warn(warning.stack);   // Print the stack trace
});
</code></pre>
<pre><code class="language-cjs">const process = require(&#39;node:process&#39;);

process.on(&#39;warning&#39;, (warning) =&gt; {
  console.warn(warning.name);    // Print the warning name
  console.warn(warning.message); // Print the warning message
  console.warn(warning.stack);   // Print the stack trace
});
</code></pre>
<p>By default, Node.js will print process warnings to <code>stderr</code>. The <code>--no-warnings</code>
command-line option can be used to suppress the default console output but the
<code>&#39;warning&#39;</code> event will still be emitted by the <code>process</code> object.</p>
<p>The following example illustrates the warning that is printed to <code>stderr</code> when
too many listeners have been added to an event:</p>
<pre><code class="language-console">$ node
&gt; events.defaultMaxListeners = 1;
&gt; process.on(&#39;foo&#39;, () =&gt; {});
&gt; process.on(&#39;foo&#39;, () =&gt; {});
&gt; (node:38638) MaxListenersExceededWarning: Possible EventEmitter memory leak
detected. 2 foo listeners added. Use emitter.setMaxListeners() to increase limit
</code></pre>
<p>In contrast, the following example turns off the default warning output and
adds a custom handler to the <code>&#39;warning&#39;</code> event:</p>
<pre><code class="language-console">$ node --no-warnings
&gt; const p = process.on(&#39;warning&#39;, (warning) =&gt; console.warn(&#39;Do not do that!&#39;));
&gt; events.defaultMaxListeners = 1;
&gt; process.on(&#39;foo&#39;, () =&gt; {});
&gt; process.on(&#39;foo&#39;, () =&gt; {});
&gt; Do not do that!
</code></pre>
<p>The <code>--trace-warnings</code> command-line option can be used to have the default
console output for warnings include the full stack trace of the warning.</p>
<p>Launching Node.js using the <code>--throw-deprecation</code> command-line flag will
cause custom deprecation warnings to be thrown as exceptions.</p>
<p>Using the <code>--trace-deprecation</code> command-line flag will cause the custom
deprecation to be printed to <code>stderr</code> along with the stack trace.</p>
<p>Using the <code>--no-deprecation</code> command-line flag will suppress all reporting
of the custom deprecation.</p>
<p>The <code>*-deprecation</code> command-line flags only affect warnings that use the name
<code>&#39;DeprecationWarning&#39;</code>.</p>
<h4>Event: <code>&#39;worker&#39;</code><span><a class="mark" href="#event-worker" id="event-worker">#</a></span><a aria-hidden="true" class="legacy" id="process_event_worker"></a></h4>
<div class="api_metadata">
<span>Added in: v16.2.0, v14.18.0</span>
</div><ul>
<li><code>worker</code> <a href="worker_threads.html#class-worker" class="type">&lt;Worker&gt;</a> The <a href="worker_threads.html#class-worker" class="type">&lt;Worker&gt;</a> that was created.</li>
</ul>
<p>The <code>&#39;worker&#39;</code> event is emitted after a new <a href="worker_threads.html#class-worker" class="type">&lt;Worker&gt;</a> thread has been created.</p>
<h5>Emitting custom warnings<span><a class="mark" href="#emitting-custom-warnings" id="emitting-custom-warnings">#</a></span><a aria-hidden="true" class="legacy" id="process_emitting_custom_warnings"></a></h5>
<p>See the <a href="#processemitwarningwarning-type-code-ctor"><code>process.emitWarning()</code></a> method for issuing
custom or application-specific warnings.</p>
<h5>Node.js warning names<span><a class="mark" href="#nodejs-warning-names" id="nodejs-warning-names">#</a></span><a aria-hidden="true" class="legacy" id="process_node_js_warning_names"></a></h5>
<p>There are no strict guidelines for warning types (as identified by the <code>name</code>
property) emitted by Node.js. New types of warnings can be added at any time.
A few of the warning types that are most common include:</p>
<ul>
<li><code>&#39;DeprecationWarning&#39;</code> - Indicates use of a deprecated Node.js API or feature.
Such warnings must include a <code>&#39;code&#39;</code> property identifying the
<a href="deprecations.html">deprecation code</a>.</li>
<li><code>&#39;ExperimentalWarning&#39;</code> - Indicates use of an experimental Node.js API or
feature. Such features must be used with caution as they may change at any
time and are not subject to the same strict semantic-versioning and long-term
support policies as supported features.</li>
<li><code>&#39;MaxListenersExceededWarning&#39;</code> - Indicates that too many listeners for a
given event have been registered on either an <code>EventEmitter</code> or <code>EventTarget</code>.
This is often an indication of a memory leak.</li>
<li><code>&#39;TimeoutOverflowWarning&#39;</code> - Indicates that a numeric value that cannot fit
within a 32-bit signed integer has been provided to either the <code>setTimeout()</code>
or <code>setInterval()</code> functions.</li>
<li><code>&#39;UnsupportedWarning&#39;</code> - Indicates use of an unsupported option or feature
that will be ignored rather than treated as an error. One example is use of
the HTTP response status message when using the HTTP/2 compatibility API.</li>
</ul>
<h4>Signal events<span><a class="mark" href="#signal-events" id="signal-events">#</a></span><a aria-hidden="true" class="legacy" id="process_signal_events"></a></h4>
<!--type=event-->

<!--name=SIGINT, SIGHUP, etc.-->

<p>Signal events will be emitted when the Node.js process receives a signal. Please
refer to <a href="http://man7.org/linux/man-pages/man7/signal.7.html"><code>signal(7)</code></a> for a listing of standard POSIX signal names such as
<code>&#39;SIGINT&#39;</code>, <code>&#39;SIGHUP&#39;</code>, etc.</p>
<p>Signals are not available on <a href="worker_threads.html#class-worker"><code>Worker</code></a> threads.</p>
<p>The signal handler will receive the signal&#39;s name (<code>&#39;SIGINT&#39;</code>,
<code>&#39;SIGTERM&#39;</code>, etc.) as the first argument.</p>
<p>The name of each event will be the uppercase common name for the signal (e.g.
<code>&#39;SIGINT&#39;</code> for <code>SIGINT</code> signals).</p>
<pre><code class="language-mjs">import process from &#39;node:process&#39;;

// Begin reading from stdin so the process does not exit.
process.stdin.resume();

process.on(&#39;SIGINT&#39;, () =&gt; {
  console.log(&#39;Received SIGINT. Press Control-D to exit.&#39;);
});

// Using a single function to handle multiple signals
function handle(signal) {
  console.log(`Received ${signal}`);
}

process.on(&#39;SIGINT&#39;, handle);
process.on(&#39;SIGTERM&#39;, handle);
</code></pre>
<pre><code class="language-cjs">const process = require(&#39;node:process&#39;);

// Begin reading from stdin so the process does not exit.
process.stdin.resume();

process.on(&#39;SIGINT&#39;, () =&gt; {
  console.log(&#39;Received SIGINT. Press Control-D to exit.&#39;);
});

// Using a single function to handle multiple signals
function handle(signal) {
  console.log(`Received ${signal}`);
}

process.on(&#39;SIGINT&#39;, handle);
process.on(&#39;SIGTERM&#39;, handle);
</code></pre>
<ul>
<li><code>&#39;SIGUSR1&#39;</code> is reserved by Node.js to start the <a href="debugger.html">debugger</a>. It&#39;s possible to
install a listener but doing so might interfere with the debugger.</li>
<li><code>&#39;SIGTERM&#39;</code> and <code>&#39;SIGINT&#39;</code> have default handlers on non-Windows platforms that
reset the terminal mode before exiting with code <code>128 + signal number</code>. If one
of these signals has a listener installed, its default behavior will be
removed (Node.js will no longer exit).</li>
<li><code>&#39;SIGPIPE&#39;</code> is ignored by default. It can have a listener installed.</li>
<li><code>&#39;SIGHUP&#39;</code> is generated on Windows when the console window is closed, and on
other platforms under various similar conditions. See <a href="http://man7.org/linux/man-pages/man7/signal.7.html"><code>signal(7)</code></a>. It can have a
listener installed, however Node.js will be unconditionally terminated by
Windows about 10 seconds later. On non-Windows platforms, the default
behavior of <code>SIGHUP</code> is to terminate Node.js, but once a listener has been
installed its default behavior will be removed.</li>
<li><code>&#39;SIGTERM&#39;</code> is not supported on Windows, it can be listened on.</li>
<li><code>&#39;SIGINT&#39;</code> from the terminal is supported on all platforms, and can usually be
generated with <kbd>Ctrl</kbd>+<kbd>C</kbd> (though this may be configurable).
It is not generated when <a href="tty.html#readstreamsetrawmodemode">terminal raw mode</a> is enabled
and <kbd>Ctrl</kbd>+<kbd>C</kbd> is used.</li>
<li><code>&#39;SIGBREAK&#39;</code> is delivered on Windows when <kbd>Ctrl</kbd>+<kbd>Break</kbd> is
pressed. On non-Windows platforms, it can be listened on, but there is no way
to send or generate it.</li>
<li><code>&#39;SIGWINCH&#39;</code> is delivered when the console has been resized. On Windows, this
will only happen on write to the console when the cursor is being moved, or
when a readable tty is used in raw mode.</li>
<li><code>&#39;SIGKILL&#39;</code> cannot have a listener installed, it will unconditionally
terminate Node.js on all platforms.</li>
<li><code>&#39;SIGSTOP&#39;</code> cannot have a listener installed.</li>
<li><code>&#39;SIGBUS&#39;</code>, <code>&#39;SIGFPE&#39;</code>, <code>&#39;SIGSEGV&#39;</code>, and <code>&#39;SIGILL&#39;</code>, when not raised
artificially using <a href="http://man7.org/linux/man-pages/man2/kill.2.html"><code>kill(2)</code></a>, inherently leave the process in a state from
which it is not safe to call JS listeners. Doing so might cause the process
to stop responding.</li>
<li><code>0</code> can be sent to test for the existence of a process, it has no effect if
the process exists, but will throw an error if the process does not exist.</li>
</ul>
<p>Windows does not support signals so has no equivalent to termination by signal,
but Node.js offers some emulation with <a href="#processkillpid-signal"><code>process.kill()</code></a>, and
<a href="child_process.html#subprocesskillsignal"><code>subprocess.kill()</code></a>:</p>
<ul>
<li>Sending <code>SIGINT</code>, <code>SIGTERM</code>, and <code>SIGKILL</code> will cause the unconditional
termination of the target process, and afterwards, subprocess will report that
the process was terminated by signal.</li>
<li>Sending signal <code>0</code> can be used as a platform independent way to test for the
existence of a process.</li>
</ul>
</section><section><h3><code>process.abort()</code><span><a class="mark" href="#processabort" id="processabort">#</a></span><a aria-hidden="true" class="legacy" id="process_process_abort"></a></h3>
<div class="api_metadata">
<span>Added in: v0.7.0</span>
</div><p>The <code>process.abort()</code> method causes the Node.js process to exit immediately and
generate a core file.</p>
<p>This feature is not available in <a href="worker_threads.html#class-worker"><code>Worker</code></a> threads.</p>
</section><section><h3><code>process.allowedNodeEnvironmentFlags</code><span><a class="mark" href="#processallowednodeenvironmentflags" id="processallowednodeenvironmentflags">#</a></span><a aria-hidden="true" class="legacy" id="process_process_allowednodeenvironmentflags"></a></h3>
<div class="api_metadata">
<span>Added in: v10.10.0</span>
</div><ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set" class="type">&lt;Set&gt;</a></li>
</ul>
<p>The <code>process.allowedNodeEnvironmentFlags</code> property is a special,
read-only <code>Set</code> of flags allowable within the <a href="cli.html#node_optionsoptions"><code>NODE_OPTIONS</code></a>
environment variable.</p>
<p><code>process.allowedNodeEnvironmentFlags</code> extends <code>Set</code>, but overrides
<code>Set.prototype.has</code> to recognize several different possible flag
representations. <code>process.allowedNodeEnvironmentFlags.has()</code> will
return <code>true</code> in the following cases:</p>
<ul>
<li>Flags may omit leading single (<code>-</code>) or double (<code>--</code>) dashes; e.g.,
<code>inspect-brk</code> for <code>--inspect-brk</code>, or <code>r</code> for <code>-r</code>.</li>
<li>Flags passed through to V8 (as listed in <code>--v8-options</code>) may replace
one or more <em>non-leading</em> dashes for an underscore, or vice-versa;
e.g., <code>--perf_basic_prof</code>, <code>--perf-basic-prof</code>, <code>--perf_basic-prof</code>,
etc.</li>
<li>Flags may contain one or more equals (<code>=</code>) characters; all
characters after and including the first equals will be ignored;
e.g., <code>--stack-trace-limit=100</code>.</li>
<li>Flags <em>must</em> be allowable within <a href="cli.html#node_optionsoptions"><code>NODE_OPTIONS</code></a>.</li>
</ul>
<p>When iterating over <code>process.allowedNodeEnvironmentFlags</code>, flags will
appear only <em>once</em>; each will begin with one or more dashes. Flags
passed through to V8 will contain underscores instead of non-leading
dashes:</p>
<pre><code class="language-mjs">import { allowedNodeEnvironmentFlags } from &#39;node:process&#39;;

allowedNodeEnvironmentFlags.forEach((flag) =&gt; {
  // -r
  // --inspect-brk
  // --abort_on_uncaught_exception
  // ...
});
</code></pre>
<pre><code class="language-cjs">const { allowedNodeEnvironmentFlags } = require(&#39;node:process&#39;);

allowedNodeEnvironmentFlags.forEach((flag) =&gt; {
  // -r
  // --inspect-brk
  // --abort_on_uncaught_exception
  // ...
});
</code></pre>
<p>The methods <code>add()</code>, <code>clear()</code>, and <code>delete()</code> of
<code>process.allowedNodeEnvironmentFlags</code> do nothing, and will fail
silently.</p>
<p>If Node.js was compiled <em>without</em> <a href="cli.html#node_optionsoptions"><code>NODE_OPTIONS</code></a> support (shown in
<a href="#processconfig"><code>process.config</code></a>), <code>process.allowedNodeEnvironmentFlags</code> will
contain what <em>would have</em> been allowable.</p>
</section><section><h3><code>process.arch</code><span><a class="mark" href="#processarch" id="processarch">#</a></span><a aria-hidden="true" class="legacy" id="process_process_arch"></a></h3>
<div class="api_metadata">
<span>Added in: v0.5.0</span>
</div><ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a></li>
</ul>
<p>The operating system CPU architecture for which the Node.js binary was compiled.
Possible values are: <code>&#39;arm&#39;</code>, <code>&#39;arm64&#39;</code>, <code>&#39;ia32&#39;</code>, <code>&#39;mips&#39;</code>,<code>&#39;mipsel&#39;</code>, <code>&#39;ppc&#39;</code>,
<code>&#39;ppc64&#39;</code>, <code>&#39;s390&#39;</code>, <code>&#39;s390x&#39;</code>, and <code>&#39;x64&#39;</code>.</p>
<pre><code class="language-mjs">import { arch } from &#39;node:process&#39;;

console.log(`This processor architecture is ${arch}`);
</code></pre>
<pre><code class="language-cjs">const { arch } = require(&#39;node:process&#39;);

console.log(`This processor architecture is ${arch}`);
</code></pre>
</section><section><h3><code>process.argv</code><span><a class="mark" href="#processargv" id="processargv">#</a></span><a aria-hidden="true" class="legacy" id="process_process_argv"></a></h3>
<div class="api_metadata">
<span>Added in: v0.1.27</span>
</div><ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string[]&gt;</a></li>
</ul>
<p>The <code>process.argv</code> property returns an array containing the command-line
arguments passed when the Node.js process was launched. The first element will
be <a href="#processexecpath"><code>process.execPath</code></a>. See <code>process.argv0</code> if access to the original value
of <code>argv[0]</code> is needed. The second element will be the path to the JavaScript
file being executed. The remaining elements will be any additional command-line
arguments.</p>
<p>For example, assuming the following script for <code>process-args.js</code>:</p>
<pre><code class="language-mjs">import { argv } from &#39;node:process&#39;;

// print process.argv
argv.forEach((val, index) =&gt; {
  console.log(`${index}: ${val}`);
});
</code></pre>
<pre><code class="language-cjs">const { argv } = require(&#39;node:process&#39;);

// print process.argv
argv.forEach((val, index) =&gt; {
  console.log(`${index}: ${val}`);
});
</code></pre>
<p>Launching the Node.js process as:</p>
<pre><code class="language-console">$ node process-args.js one two=three four
</code></pre>
<p>Would generate the output:</p>
<pre><code class="language-text">0: /usr/local/bin/node
1: /Users/mjr/work/node/process-args.js
2: one
3: two=three
4: four
</code></pre>
</section><section><h3><code>process.argv0</code><span><a class="mark" href="#processargv0" id="processargv0">#</a></span><a aria-hidden="true" class="legacy" id="process_process_argv0"></a></h3>
<div class="api_metadata">
<span>Added in: v6.4.0</span>
</div><ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a></li>
</ul>
<p>The <code>process.argv0</code> property stores a read-only copy of the original value of
<code>argv[0]</code> passed when Node.js starts.</p>
<pre><code class="language-console">$ bash -c &#39;exec -a customArgv0 ./node&#39;
&gt; process.argv[0]
&#39;/Volumes/code/external/node/out/Release/node&#39;
&gt; process.argv0
&#39;customArgv0&#39;
</code></pre>
</section><section><h3><code>process.channel</code><span><a class="mark" href="#processchannel" id="processchannel">#</a></span><a aria-hidden="true" class="legacy" id="process_process_channel"></a></h3>
<div class="api_metadata">
<details class="changelog"><summary>History</summary>
<table>
<tr><th>Version</th><th>Changes</th></tr>
<tr><td>v14.0.0</td>
<td><p>The object no longer accidentally exposes native C++ bindings.</p>
</td></tr>
<tr><td>v7.1.0</td>
<td><p><span>Added in: v7.1.0</span></p>
</td></tr>
</table>
</details>
</div><ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type">&lt;Object&gt;</a></li>
</ul>
<p>If the Node.js process was spawned with an IPC channel (see the
<a href="child_process.html">Child Process</a> documentation), the <code>process.channel</code>
property is a reference to the IPC channel. If no IPC channel exists, this
property is <code>undefined</code>.</p>
<h4><code>process.channel.ref()</code><span><a class="mark" href="#processchannelref" id="processchannelref">#</a></span><a aria-hidden="true" class="legacy" id="process_process_channel_ref"></a></h4>
<div class="api_metadata">
<span>Added in: v7.1.0</span>
</div><p>This method makes the IPC channel keep the event loop of the process
running if <code>.unref()</code> has been called before.</p>
<p>Typically, this is managed through the number of <code>&#39;disconnect&#39;</code> and <code>&#39;message&#39;</code>
listeners on the <code>process</code> object. However, this method can be used to
explicitly request a specific behavior.</p>
<h4><code>process.channel.unref()</code><span><a class="mark" href="#processchannelunref" id="processchannelunref">#</a></span><a aria-hidden="true" class="legacy" id="process_process_channel_unref"></a></h4>
<div class="api_metadata">
<span>Added in: v7.1.0</span>
</div><p>This method makes the IPC channel not keep the event loop of the process
running, and lets it finish even while the channel is open.</p>
<p>Typically, this is managed through the number of <code>&#39;disconnect&#39;</code> and <code>&#39;message&#39;</code>
listeners on the <code>process</code> object. However, this method can be used to
explicitly request a specific behavior.</p>
</section><section><h3><code>process.chdir(directory)</code><span><a class="mark" href="#processchdirdirectory" id="processchdirdirectory">#</a></span><a aria-hidden="true" class="legacy" id="process_process_chdir_directory"></a></h3>
<div class="api_metadata">
<span>Added in: v0.1.17</span>
</div><ul>
<li><code>directory</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a></li>
</ul>
<p>The <code>process.chdir()</code> method changes the current working directory of the
Node.js process or throws an exception if doing so fails (for instance, if
the specified <code>directory</code> does not exist).</p>
<pre><code class="language-mjs">import { chdir, cwd } from &#39;node:process&#39;;

console.log(`Starting directory: ${cwd()}`);
try {
  chdir(&#39;/tmp&#39;);
  console.log(`New directory: ${cwd()}`);
} catch (err) {
  console.error(`chdir: ${err}`);
}
</code></pre>
<pre><code class="language-cjs">const { chdir, cwd } = require(&#39;node:process&#39;);

console.log(`Starting directory: ${cwd()}`);
try {
  chdir(&#39;/tmp&#39;);
  console.log(`New directory: ${cwd()}`);
} catch (err) {
  console.error(`chdir: ${err}`);
}
</code></pre>
<p>This feature is not available in <a href="worker_threads.html#class-worker"><code>Worker</code></a> threads.</p>
</section><section><h3><code>process.config</code><span><a class="mark" href="#processconfig" id="processconfig">#</a></span><a aria-hidden="true" class="legacy" id="process_process_config"></a></h3>
<div class="api_metadata">
<details class="changelog"><summary>History</summary>
<table>
<tr><th>Version</th><th>Changes</th></tr>
<tr><td>v16.0.0</td>
<td><p>Modifying process.config has been deprecated.</p>
</td></tr>
<tr><td>v0.7.7</td>
<td><p><span>Added in: v0.7.7</span></p>
</td></tr>
</table>
</details>
</div><ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type">&lt;Object&gt;</a></li>
</ul>
<p>The <code>process.config</code> property returns an <code>Object</code> containing the JavaScript
representation of the configure options used to compile the current Node.js
executable. This is the same as the <code>config.gypi</code> file that was produced when
running the <code>./configure</code> script.</p>
<p>An example of the possible output looks like:</p>
<!-- eslint-skip -->

<pre><code class="language-js">{
  target_defaults:
   { cflags: [],
     default_configuration: &#39;Release&#39;,
     defines: [],
     include_dirs: [],
     libraries: [] },
  variables:
   {
     host_arch: &#39;x64&#39;,
     napi_build_version: 5,
     node_install_npm: &#39;true&#39;,
     node_prefix: &#39;&#39;,
     node_shared_cares: &#39;false&#39;,
     node_shared_http_parser: &#39;false&#39;,
     node_shared_libuv: &#39;false&#39;,
     node_shared_zlib: &#39;false&#39;,
     node_use_dtrace: &#39;false&#39;,
     node_use_openssl: &#39;true&#39;,
     node_shared_openssl: &#39;false&#39;,
     strict_aliasing: &#39;true&#39;,
     target_arch: &#39;x64&#39;,
     v8_use_snapshot: 1
   }
}
</code></pre>
<p>The <code>process.config</code> property is <strong>not</strong> read-only and there are existing
modules in the ecosystem that are known to extend, modify, or entirely replace
the value of <code>process.config</code>.</p>
<p>Modifying the <code>process.config</code> property, or any child-property of the
<code>process.config</code> object has been deprecated. The <code>process.config</code> will be made
read-only in a future release.</p>
</section><section><h3><code>process.connected</code><span><a class="mark" href="#processconnected" id="processconnected">#</a></span><a aria-hidden="true" class="legacy" id="process_process_connected"></a></h3>
<div class="api_metadata">
<span>Added in: v0.7.2</span>
</div><ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type" class="type">&lt;boolean&gt;</a></li>
</ul>
<p>If the Node.js process is spawned with an IPC channel (see the <a href="child_process.html">Child Process</a>
and <a href="cluster.html">Cluster</a> documentation), the <code>process.connected</code> property will return
<code>true</code> so long as the IPC channel is connected and will return <code>false</code> after
<code>process.disconnect()</code> is called.</p>
<p>Once <code>process.connected</code> is <code>false</code>, it is no longer possible to send messages
over the IPC channel using <code>process.send()</code>.</p>
</section><section><h3><code>process.constrainedMemory()</code><span><a class="mark" href="#processconstrainedmemory" id="processconstrainedmemory">#</a></span><a aria-hidden="true" class="legacy" id="process_process_constrainedmemory"></a></h3>
<div class="api_metadata">
<span>Added in: v18.15.0</span>
</div><blockquote>
<p>Stability: 1 - Experimental</p>
</blockquote>
<ul>
<li>{number|undefined}</li>
</ul>
<p>Gets the amount of memory available to the process (in bytes) based on
limits imposed by the OS. If there is no such constraint, or the constraint
is unknown, <code>undefined</code> is returned.</p>
<p>See <a href="https://docs.libuv.org/en/v1.x/misc.html#c.uv_get_constrained_memory"><code>uv_get_constrained_memory</code></a> for more
information.</p>
</section><section><h3><code>process.cpuUsage([previousValue])</code><span><a class="mark" href="#processcpuusagepreviousvalue" id="processcpuusagepreviousvalue">#</a></span><a aria-hidden="true" class="legacy" id="process_process_cpuusage_previousvalue"></a></h3>
<div class="api_metadata">
<span>Added in: v6.1.0</span>
</div><ul>
<li><code>previousValue</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type">&lt;Object&gt;</a> A previous return value from calling
<code>process.cpuUsage()</code></li>
<li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type">&lt;Object&gt;</a><ul>
<li><code>user</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer&gt;</a></li>
<li><code>system</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer&gt;</a></li>
</ul>
</li>
</ul>
<p>The <code>process.cpuUsage()</code> method returns the user and system CPU time usage of
the current process, in an object with properties <code>user</code> and <code>system</code>, whose
values are microsecond values (millionth of a second). These values measure time
spent in user and system code respectively, and may end up being greater than
actual elapsed time if multiple CPU cores are performing work for this process.</p>
<p>The result of a previous call to <code>process.cpuUsage()</code> can be passed as the
argument to the function, to get a diff reading.</p>
<pre><code class="language-mjs">import { cpuUsage } from &#39;node:process&#39;;

const startUsage = cpuUsage();
// { user: 38579, system: 6986 }

// spin the CPU for 500 milliseconds
const now = Date.now();
while (Date.now() - now &lt; 500);

console.log(cpuUsage(startUsage));
// { user: 514883, system: 11226 }
</code></pre>
<pre><code class="language-cjs">const { cpuUsage } = require(&#39;node:process&#39;);

const startUsage = cpuUsage();
// { user: 38579, system: 6986 }

// spin the CPU for 500 milliseconds
const now = Date.now();
while (Date.now() - now &lt; 500);

console.log(cpuUsage(startUsage));
// { user: 514883, system: 11226 }
</code></pre>
</section><section><h3><code>process.cwd()</code><span><a class="mark" href="#processcwd" id="processcwd">#</a></span><a aria-hidden="true" class="legacy" id="process_process_cwd"></a></h3>
<div class="api_metadata">
<span>Added in: v0.1.8</span>
</div><ul>
<li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a></li>
</ul>
<p>The <code>process.cwd()</code> method returns the current working directory of the Node.js
process.</p>
<pre><code class="language-mjs">import { cwd } from &#39;node:process&#39;;

console.log(`Current directory: ${cwd()}`);
</code></pre>
<pre><code class="language-cjs">const { cwd } = require(&#39;node:process&#39;);

console.log(`Current directory: ${cwd()}`);
</code></pre>
</section><section><h3><code>process.debugPort</code><span><a class="mark" href="#processdebugport" id="processdebugport">#</a></span><a aria-hidden="true" class="legacy" id="process_process_debugport"></a></h3>
<div class="api_metadata">
<span>Added in: v0.7.2</span>
</div><ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;number&gt;</a></li>
</ul>
<p>The port used by the Node.js debugger when enabled.</p>
<pre><code class="language-mjs">import process from &#39;node:process&#39;;

process.debugPort = 5858;
</code></pre>
<pre><code class="language-cjs">const process = require(&#39;node:process&#39;);

process.debugPort = 5858;
</code></pre>
</section><section><h3><code>process.disconnect()</code><span><a class="mark" href="#processdisconnect" id="processdisconnect">#</a></span><a aria-hidden="true" class="legacy" id="process_process_disconnect"></a></h3>
<div class="api_metadata">
<span>Added in: v0.7.2</span>
</div><p>If the Node.js process is spawned with an IPC channel (see the <a href="child_process.html">Child Process</a>
and <a href="cluster.html">Cluster</a> documentation), the <code>process.disconnect()</code> method will close the
IPC channel to the parent process, allowing the child process to exit gracefully
once there are no other connections keeping it alive.</p>
<p>The effect of calling <code>process.disconnect()</code> is the same as calling
<a href="child_process.html#subprocessdisconnect"><code>ChildProcess.disconnect()</code></a> from the parent process.</p>
<p>If the Node.js process was not spawned with an IPC channel,
<code>process.disconnect()</code> will be <code>undefined</code>.</p>
</section><section><h3><code>process.dlopen(module, filename[, flags])</code><span><a class="mark" href="#processdlopenmodule-filename-flags" id="processdlopenmodule-filename-flags">#</a></span><a aria-hidden="true" class="legacy" id="process_process_dlopen_module_filename_flags"></a></h3>
<div class="api_metadata">
<details class="changelog"><summary>History</summary>
<table>
<tr><th>Version</th><th>Changes</th></tr>
<tr><td>v9.0.0</td>
<td><p>Added support for the <code>flags</code> argument.</p>
</td></tr>
<tr><td>v0.1.16</td>
<td><p><span>Added in: v0.1.16</span></p>
</td></tr>
</table>
</details>
</div><ul>
<li><code>module</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type">&lt;Object&gt;</a></li>
<li><code>filename</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a></li>
<li><code>flags</code> {os.constants.dlopen} <strong>Default:</strong> <code>os.constants.dlopen.RTLD_LAZY</code></li>
</ul>
<p>The <code>process.dlopen()</code> method allows dynamically loading shared objects. It is
primarily used by <code>require()</code> to load C++ Addons, and should not be used
directly, except in special cases. In other words, <a href="globals.html#require"><code>require()</code></a> should be
preferred over <code>process.dlopen()</code> unless there are specific reasons such as
custom dlopen flags or loading from ES modules.</p>
<p>The <code>flags</code> argument is an integer that allows to specify dlopen
behavior. See the <a href="os.html#dlopen-constants"><code>os.constants.dlopen</code></a> documentation for details.</p>
<p>An important requirement when calling <code>process.dlopen()</code> is that the <code>module</code>
instance must be passed. Functions exported by the C++ Addon are then
accessible via <code>module.exports</code>.</p>
<p>The example below shows how to load a C++ Addon, named <code>local.node</code>,
that exports a <code>foo</code> function. All the symbols are loaded before
the call returns, by passing the <code>RTLD_NOW</code> constant. In this example
the constant is assumed to be available.</p>
<pre><code class="language-mjs">import { dlopen } from &#39;node:process&#39;;
import { constants } from &#39;node:os&#39;;
import { fileURLToPath } from &#39;node:url&#39;;

const module = { exports: {} };
dlopen(module, fileURLToPath(new URL(&#39;local.node&#39;, import.meta.url)),
       constants.dlopen.RTLD_NOW);
module.exports.foo();
</code></pre>
<pre><code class="language-cjs">const { dlopen } = require(&#39;node:process&#39;);
const { constants } = require(&#39;node:os&#39;);
const { join } = require(&#39;node:path&#39;);

const module = { exports: {} };
dlopen(module, join(__dirname, &#39;local.node&#39;), constants.dlopen.RTLD_NOW);
module.exports.foo();
</code></pre>
</section><section><h3><code>process.emitWarning(warning[, options])</code><span><a class="mark" href="#processemitwarningwarning-options" id="processemitwarningwarning-options">#</a></span><a aria-hidden="true" class="legacy" id="process_process_emitwarning_warning_options"></a></h3>
<div class="api_metadata">
<span>Added in: v8.0.0</span>
</div><ul>
<li><code>warning</code> {string|Error} The warning to emit.</li>
<li><code>options</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type">&lt;Object&gt;</a><ul>
<li><code>type</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> When <code>warning</code> is a <code>String</code>, <code>type</code> is the name to use
for the <em>type</em> of warning being emitted. <strong>Default:</strong> <code>&#39;Warning&#39;</code>.</li>
<li><code>code</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> A unique identifier for the warning instance being emitted.</li>
<li><code>ctor</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function" class="type">&lt;Function&gt;</a> When <code>warning</code> is a <code>String</code>, <code>ctor</code> is an optional
function used to limit the generated stack trace. <strong>Default:</strong>
<code>process.emitWarning</code>.</li>
<li><code>detail</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> Additional text to include with the error.</li>
</ul>
</li>
</ul>
<p>The <code>process.emitWarning()</code> method can be used to emit custom or application
specific process warnings. These can be listened for by adding a handler to the
<a href="#event-warning"><code>&#39;warning&#39;</code></a> event.</p>
<pre><code class="language-mjs">import { emitWarning } from &#39;node:process&#39;;

// Emit a warning with a code and additional detail.
emitWarning(&#39;Something happened!&#39;, {
  code: &#39;MY_WARNING&#39;,
  detail: &#39;This is some additional information&#39;,
});
// Emits:
// (node:56338) [MY_WARNING] Warning: Something happened!
// This is some additional information
</code></pre>
<pre><code class="language-cjs">const { emitWarning } = require(&#39;node:process&#39;);

// Emit a warning with a code and additional detail.
emitWarning(&#39;Something happened!&#39;, {
  code: &#39;MY_WARNING&#39;,
  detail: &#39;This is some additional information&#39;,
});
// Emits:
// (node:56338) [MY_WARNING] Warning: Something happened!
// This is some additional information
</code></pre>
<p>In this example, an <code>Error</code> object is generated internally by
<code>process.emitWarning()</code> and passed through to the
<a href="#event-warning"><code>&#39;warning&#39;</code></a> handler.</p>
<pre><code class="language-mjs">import process from &#39;node:process&#39;;

process.on(&#39;warning&#39;, (warning) =&gt; {
  console.warn(warning.name);    // &#39;Warning&#39;
  console.warn(warning.message); // &#39;Something happened!&#39;
  console.warn(warning.code);    // &#39;MY_WARNING&#39;
  console.warn(warning.stack);   // Stack trace
  console.warn(warning.detail);  // &#39;This is some additional information&#39;
});
</code></pre>
<pre><code class="language-cjs">const process = require(&#39;node:process&#39;);

process.on(&#39;warning&#39;, (warning) =&gt; {
  console.warn(warning.name);    // &#39;Warning&#39;
  console.warn(warning.message); // &#39;Something happened!&#39;
  console.warn(warning.code);    // &#39;MY_WARNING&#39;
  console.warn(warning.stack);   // Stack trace
  console.warn(warning.detail);  // &#39;This is some additional information&#39;
});
</code></pre>
<p>If <code>warning</code> is passed as an <code>Error</code> object, the <code>options</code> argument is ignored.</p>
</section><section><h3><code>process.emitWarning(warning[, type[, code]][, ctor])</code><span><a class="mark" href="#processemitwarningwarning-type-code-ctor" id="processemitwarningwarning-type-code-ctor">#</a></span><a aria-hidden="true" class="legacy" id="process_process_emitwarning_warning_type_code_ctor"></a></h3>
<div class="api_metadata">
<span>Added in: v6.0.0</span>
</div><ul>
<li><code>warning</code> {string|Error} The warning to emit.</li>
<li><code>type</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> When <code>warning</code> is a <code>String</code>, <code>type</code> is the name to use
for the <em>type</em> of warning being emitted. <strong>Default:</strong> <code>&#39;Warning&#39;</code>.</li>
<li><code>code</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> A unique identifier for the warning instance being emitted.</li>
<li><code>ctor</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function" class="type">&lt;Function&gt;</a> When <code>warning</code> is a <code>String</code>, <code>ctor</code> is an optional
function used to limit the generated stack trace. <strong>Default:</strong>
<code>process.emitWarning</code>.</li>
</ul>
<p>The <code>process.emitWarning()</code> method can be used to emit custom or application
specific process warnings. These can be listened for by adding a handler to the
<a href="#event-warning"><code>&#39;warning&#39;</code></a> event.</p>
<pre><code class="language-mjs">import { emitWarning } from &#39;node:process&#39;;

// Emit a warning using a string.
emitWarning(&#39;Something happened!&#39;);
// Emits: (node: 56338) Warning: Something happened!
</code></pre>
<pre><code class="language-cjs">const { emitWarning } = require(&#39;node:process&#39;);

// Emit a warning using a string.
emitWarning(&#39;Something happened!&#39;);
// Emits: (node: 56338) Warning: Something happened!
</code></pre>
<pre><code class="language-mjs">import { emitWarning } from &#39;node:process&#39;;

// Emit a warning using a string and a type.
emitWarning(&#39;Something Happened!&#39;, &#39;CustomWarning&#39;);
// Emits: (node:56338) CustomWarning: Something Happened!
</code></pre>
<pre><code class="language-cjs">const { emitWarning } = require(&#39;node:process&#39;);

// Emit a warning using a string and a type.
emitWarning(&#39;Something Happened!&#39;, &#39;CustomWarning&#39;);
// Emits: (node:56338) CustomWarning: Something Happened!
</code></pre>
<pre><code class="language-mjs">import { emitWarning } from &#39;node:process&#39;;

emitWarning(&#39;Something happened!&#39;, &#39;CustomWarning&#39;, &#39;WARN001&#39;);
// Emits: (node:56338) [WARN001] CustomWarning: Something happened!
</code></pre>
<pre><code class="language-cjs">const { emitWarning } = require(&#39;node:process&#39;);

process.emitWarning(&#39;Something happened!&#39;, &#39;CustomWarning&#39;, &#39;WARN001&#39;);
// Emits: (node:56338) [WARN001] CustomWarning: Something happened!
</code></pre>
<p>In each of the previous examples, an <code>Error</code> object is generated internally by
<code>process.emitWarning()</code> and passed through to the <a href="#event-warning"><code>&#39;warning&#39;</code></a>
handler.</p>
<pre><code class="language-mjs">import process from &#39;node:process&#39;;

process.on(&#39;warning&#39;, (warning) =&gt; {
  console.warn(warning.name);
  console.warn(warning.message);
  console.warn(warning.code);
  console.warn(warning.stack);
});
</code></pre>
<pre><code class="language-cjs">const process = require(&#39;node:process&#39;);

process.on(&#39;warning&#39;, (warning) =&gt; {
  console.warn(warning.name);
  console.warn(warning.message);
  console.warn(warning.code);
  console.warn(warning.stack);
});
</code></pre>
<p>If <code>warning</code> is passed as an <code>Error</code> object, it will be passed through to the
<code>&#39;warning&#39;</code> event handler unmodified (and the optional <code>type</code>,
<code>code</code> and <code>ctor</code> arguments will be ignored):</p>
<pre><code class="language-mjs">import { emitWarning } from &#39;node:process&#39;;

// Emit a warning using an Error object.
const myWarning = new Error(&#39;Something happened!&#39;);
// Use the Error name property to specify the type name
myWarning.name = &#39;CustomWarning&#39;;
myWarning.code = &#39;WARN001&#39;;

emitWarning(myWarning);
// Emits: (node:56338) [WARN001] CustomWarning: Something happened!
</code></pre>
<pre><code class="language-cjs">const { emitWarning } = require(&#39;node:process&#39;);

// Emit a warning using an Error object.
const myWarning = new Error(&#39;Something happened!&#39;);
// Use the Error name property to specify the type name
myWarning.name = &#39;CustomWarning&#39;;
myWarning.code = &#39;WARN001&#39;;

emitWarning(myWarning);
// Emits: (node:56338) [WARN001] CustomWarning: Something happened!
</code></pre>
<p>A <code>TypeError</code> is thrown if <code>warning</code> is anything other than a string or <code>Error</code>
object.</p>
<p>While process warnings use <code>Error</code> objects, the process warning
mechanism is <strong>not</strong> a replacement for normal error handling mechanisms.</p>
<p>The following additional handling is implemented if the warning <code>type</code> is
<code>&#39;DeprecationWarning&#39;</code>:</p>
<ul>
<li>If the <code>--throw-deprecation</code> command-line flag is used, the deprecation
warning is thrown as an exception rather than being emitted as an event.</li>
<li>If the <code>--no-deprecation</code> command-line flag is used, the deprecation
warning is suppressed.</li>
<li>If the <code>--trace-deprecation</code> command-line flag is used, the deprecation
warning is printed to <code>stderr</code> along with the full stack trace.</li>
</ul>
<h4>Avoiding duplicate warnings<span><a class="mark" href="#avoiding-duplicate-warnings" id="avoiding-duplicate-warnings">#</a></span><a aria-hidden="true" class="legacy" id="process_avoiding_duplicate_warnings"></a></h4>
<p>As a best practice, warnings should be emitted only once per process. To do
so, place the <code>emitWarning()</code> behind a boolean.</p>
<pre><code class="language-mjs">import { emitWarning } from &#39;node:process&#39;;

function emitMyWarning() {
  if (!emitMyWarning.warned) {
    emitMyWarning.warned = true;
    emitWarning(&#39;Only warn once!&#39;);
  }
}
emitMyWarning();
// Emits: (node: 56339) Warning: Only warn once!
emitMyWarning();
// Emits nothing
</code></pre>
<pre><code class="language-cjs">const { emitWarning } = require(&#39;node:process&#39;);

function emitMyWarning() {
  if (!emitMyWarning.warned) {
    emitMyWarning.warned = true;
    emitWarning(&#39;Only warn once!&#39;);
  }
}
emitMyWarning();
// Emits: (node: 56339) Warning: Only warn once!
emitMyWarning();
// Emits nothing
</code></pre>
</section><section><h3><code>process.env</code><span><a class="mark" href="#processenv" id="processenv">#</a></span><a aria-hidden="true" class="legacy" id="process_process_env"></a></h3>
<div class="api_metadata">
<details class="changelog"><summary>History</summary>
<table>
<tr><th>Version</th><th>Changes</th></tr>
<tr><td>v11.14.0</td>
<td><p>Worker threads will now use a copy of the parent thread&#39;s <code>process.env</code> by default, configurable through the <code>env</code> option of the <code>Worker</code> constructor.</p>
</td></tr>
<tr><td>v10.0.0</td>
<td><p>Implicit conversion of variable value to string is deprecated.</p>
</td></tr>
<tr><td>v0.1.27</td>
<td><p><span>Added in: v0.1.27</span></p>
</td></tr>
</table>
</details>
</div><ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type">&lt;Object&gt;</a></li>
</ul>
<p>The <code>process.env</code> property returns an object containing the user environment.
See <a href="http://man7.org/linux/man-pages/man7/environ.7.html"><code>environ(7)</code></a>.</p>
<p>An example of this object looks like:</p>
<!-- eslint-skip -->

<pre><code class="language-js">{
  TERM: &#39;xterm-256color&#39;,
  SHELL: &#39;/usr/local/bin/bash&#39;,
  USER: &#39;maciej&#39;,
  PATH: &#39;~/.bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin&#39;,
  PWD: &#39;/Users/maciej&#39;,
  EDITOR: &#39;vim&#39;,
  SHLVL: &#39;1&#39;,
  HOME: &#39;/Users/maciej&#39;,
  LOGNAME: &#39;maciej&#39;,
  _: &#39;/usr/local/bin/node&#39;
}
</code></pre>
<p>It is possible to modify this object, but such modifications will not be
reflected outside the Node.js process, or (unless explicitly requested)
to other <a href="worker_threads.html#class-worker"><code>Worker</code></a> threads.
In other words, the following example would not work:</p>
<pre><code class="language-console">$ node -e &#39;process.env.foo = &quot;bar&quot;&#39; &amp;&amp; echo $foo
</code></pre>
<p>While the following will:</p>
<pre><code class="language-mjs">import { env } from &#39;node:process&#39;;

env.foo = &#39;bar&#39;;
console.log(env.foo);
</code></pre>
<pre><code class="language-cjs">const { env } = require(&#39;node:process&#39;);

env.foo = &#39;bar&#39;;
console.log(env.foo);
</code></pre>
<p>Assigning a property on <code>process.env</code> will implicitly convert the value
to a string. <strong>This behavior is deprecated.</strong> Future versions of Node.js may
throw an error when the value is not a string, number, or boolean.</p>
<pre><code class="language-mjs">import { env } from &#39;node:process&#39;;

env.test = null;
console.log(env.test);
// =&gt; &#39;null&#39;
env.test = undefined;
console.log(env.test);
// =&gt; &#39;undefined&#39;
</code></pre>
<pre><code class="language-cjs">const { env } = require(&#39;node:process&#39;);

env.test = null;
console.log(env.test);
// =&gt; &#39;null&#39;
env.test = undefined;
console.log(env.test);
// =&gt; &#39;undefined&#39;
</code></pre>
<p>Use <code>delete</code> to delete a property from <code>process.env</code>.</p>
<pre><code class="language-mjs">import { env } from &#39;node:process&#39;;

env.TEST = 1;
delete env.TEST;
console.log(env.TEST);
// =&gt; undefined
</code></pre>
<pre><code class="language-cjs">const { env } = require(&#39;node:process&#39;);

env.TEST = 1;
delete env.TEST;
console.log(env.TEST);
// =&gt; undefined
</code></pre>
<p>On Windows operating systems, environment variables are case-insensitive.</p>
<pre><code class="language-mjs">import { env } from &#39;node:process&#39;;

env.TEST = 1;
console.log(env.test);
// =&gt; 1
</code></pre>
<pre><code class="language-cjs">const { env } = require(&#39;node:process&#39;);

env.TEST = 1;
console.log(env.test);
// =&gt; 1
</code></pre>
<p>Unless explicitly specified when creating a <a href="worker_threads.html#class-worker"><code>Worker</code></a> instance,
each <a href="worker_threads.html#class-worker"><code>Worker</code></a> thread has its own copy of <code>process.env</code>, based on its
parent thread&#39;s <code>process.env</code>, or whatever was specified as the <code>env</code> option
to the <a href="worker_threads.html#class-worker"><code>Worker</code></a> constructor. Changes to <code>process.env</code> will not be visible
across <a href="worker_threads.html#class-worker"><code>Worker</code></a> threads, and only the main thread can make changes that
are visible to the operating system or to native add-ons. On Windows, a copy of
<code>process.env</code> on a <a href="worker_threads.html#class-worker"><code>Worker</code></a> instance operates in a case-sensitive manner
unlike the main thread.</p>
</section><section><h3><code>process.execArgv</code><span><a class="mark" href="#processexecargv" id="processexecargv">#</a></span><a aria-hidden="true" class="legacy" id="process_process_execargv"></a></h3>
<div class="api_metadata">
<span>Added in: v0.7.7</span>
</div><ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string[]&gt;</a></li>
</ul>
<p>The <code>process.execArgv</code> property returns the set of Node.js-specific command-line
options passed when the Node.js process was launched. These options do not
appear in the array returned by the <a href="#processargv"><code>process.argv</code></a> property, and do not
include the Node.js executable, the name of the script, or any options following
the script name. These options are useful in order to spawn child processes with
the same execution environment as the parent.</p>
<pre><code class="language-console">$ node --harmony script.js --version
</code></pre>
<p>Results in <code>process.execArgv</code>:</p>
<!-- eslint-disable semi -->

<pre><code class="language-js">[&#39;--harmony&#39;]
</code></pre>
<p>And <code>process.argv</code>:</p>
<!-- eslint-disable semi -->

<pre><code class="language-js">[&#39;/usr/local/bin/node&#39;, &#39;script.js&#39;, &#39;--version&#39;]
</code></pre>
<p>Refer to <a href="worker_threads.html#new-workerfilename-options"><code>Worker</code> constructor</a> for the detailed behavior of worker
threads with this property.</p>
</section><section><h3><code>process.execPath</code><span><a class="mark" href="#processexecpath" id="processexecpath">#</a></span><a aria-hidden="true" class="legacy" id="process_process_execpath"></a></h3>
<div class="api_metadata">
<span>Added in: v0.1.100</span>
</div><ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a></li>
</ul>
<p>The <code>process.execPath</code> property returns the absolute pathname of the executable
that started the Node.js process. Symbolic links, if any, are resolved.</p>
<!-- eslint-disable semi -->

<pre><code class="language-js">&#39;/usr/local/bin/node&#39;
</code></pre>
</section><section><h3><code>process.exit([code])</code><span><a class="mark" href="#processexitcode" id="processexitcode">#</a></span><a aria-hidden="true" class="legacy" id="process_process_exit_code"></a></h3>
<div class="api_metadata">
<span>Added in: v0.1.13</span>
</div><ul>
<li><code>code</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer&gt;</a> The exit code. <strong>Default:</strong> <code>0</code>.</li>
</ul>
<p>The <code>process.exit()</code> method instructs Node.js to terminate the process
synchronously with an exit status of <code>code</code>. If <code>code</code> is omitted, exit uses
either the &#39;success&#39; code <code>0</code> or the value of <code>process.exitCode</code> if it has been
set. Node.js will not terminate until all the <a href="#event-exit"><code>&#39;exit&#39;</code></a> event listeners are
called.</p>
<p>To exit with a &#39;failure&#39; code:</p>
<pre><code class="language-mjs">import { exit } from &#39;node:process&#39;;

exit(1);
</code></pre>
<pre><code class="language-cjs">const { exit } = require(&#39;node:process&#39;);

exit(1);
</code></pre>
<p>The shell that executed Node.js should see the exit code as <code>1</code>.</p>
<p>Calling <code>process.exit()</code> will force the process to exit as quickly as possible
even if there are still asynchronous operations pending that have not yet
completed fully, including I/O operations to <code>process.stdout</code> and
<code>process.stderr</code>.</p>
<p>In most situations, it is not actually necessary to call <code>process.exit()</code>
explicitly. The Node.js process will exit on its own <em>if there is no additional
work pending</em> in the event loop. The <code>process.exitCode</code> property can be set to
tell the process which exit code to use when the process exits gracefully.</p>
<p>For instance, the following example illustrates a <em>misuse</em> of the
<code>process.exit()</code> method that could lead to data printed to stdout being
truncated and lost:</p>
<pre><code class="language-mjs">import { exit } from &#39;node:process&#39;;

// This is an example of what *not* to do:
if (someConditionNotMet()) {
  printUsageToStdout();
  exit(1);
}
</code></pre>
<pre><code class="language-cjs">const { exit } = require(&#39;node:process&#39;);

// This is an example of what *not* to do:
if (someConditionNotMet()) {
  printUsageToStdout();
  exit(1);
}
</code></pre>
<p>The reason this is problematic is because writes to <code>process.stdout</code> in Node.js
are sometimes <em>asynchronous</em> and may occur over multiple ticks of the Node.js
event loop. Calling <code>process.exit()</code>, however, forces the process to exit
<em>before</em> those additional writes to <code>stdout</code> can be performed.</p>
<p>Rather than calling <code>process.exit()</code> directly, the code <em>should</em> set the
<code>process.exitCode</code> and allow the process to exit naturally by avoiding
scheduling any additional work for the event loop:</p>
<pre><code class="language-mjs">import process from &#39;node:process&#39;;

// How to properly set the exit code while letting
// the process exit gracefully.
if (someConditionNotMet()) {
  printUsageToStdout();
  process.exitCode = 1;
}
</code></pre>
<pre><code class="language-cjs">const process = require(&#39;node:process&#39;);

// How to properly set the exit code while letting
// the process exit gracefully.
if (someConditionNotMet()) {
  printUsageToStdout();
  process.exitCode = 1;
}
</code></pre>
<p>If it is necessary to terminate the Node.js process due to an error condition,
throwing an <em>uncaught</em> error and allowing the process to terminate accordingly
is safer than calling <code>process.exit()</code>.</p>
<p>In <a href="worker_threads.html#class-worker"><code>Worker</code></a> threads, this function stops the current thread rather
than the current process.</p>
</section><section><h3><code>process.exitCode</code><span><a class="mark" href="#processexitcode_1" id="processexitcode_1">#</a></span><a aria-hidden="true" class="legacy" id="process_process_exitcode"></a></h3>
<div class="api_metadata">
<span>Added in: v0.11.8</span>
</div><ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer&gt;</a></li>
</ul>
<p>A number which will be the process exit code, when the process either
exits gracefully, or is exited via <a href="#processexitcode"><code>process.exit()</code></a> without specifying
a code.</p>
<p>Specifying a code to <a href="#processexitcode"><code>process.exit(code)</code></a> will override any
previous setting of <code>process.exitCode</code>.</p>
</section><section><h3><code>process.getActiveResourcesInfo()</code><span><a class="mark" href="#processgetactiveresourcesinfo" id="processgetactiveresourcesinfo">#</a></span><a aria-hidden="true" class="legacy" id="process_process_getactiveresourcesinfo"></a></h3>
<div class="api_metadata">
<span>Added in: v17.3.0, v16.14.0</span>
</div><blockquote>
<p>Stability: 1 - Experimental</p>
</blockquote>
<ul>
<li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string[]&gt;</a></li>
</ul>
<p>The <code>process.getActiveResourcesInfo()</code> method returns an array of strings
containing the types of the active resources that are currently keeping the
event loop alive.</p>
<pre><code class="language-mjs">import { getActiveResourcesInfo } from &#39;node:process&#39;;
import { setTimeout } from &#39;node:timers&#39;;

console.log(&#39;Before:&#39;, getActiveResourcesInfo());
setTimeout(() =&gt; {}, 1000);
console.log(&#39;After:&#39;, getActiveResourcesInfo());
// Prints:
//   Before: [ &#39;CloseReq&#39;, &#39;TTYWrap&#39;, &#39;TTYWrap&#39;, &#39;TTYWrap&#39; ]
//   After: [ &#39;CloseReq&#39;, &#39;TTYWrap&#39;, &#39;TTYWrap&#39;, &#39;TTYWrap&#39;, &#39;Timeout&#39; ]
</code></pre>
<pre><code class="language-cjs">const { getActiveResourcesInfo } = require(&#39;node:process&#39;);
const { setTimeout } = require(&#39;node:timers&#39;);

console.log(&#39;Before:&#39;, getActiveResourcesInfo());
setTimeout(() =&gt; {}, 1000);
console.log(&#39;After:&#39;, getActiveResourcesInfo());
// Prints:
//   Before: [ &#39;TTYWrap&#39;, &#39;TTYWrap&#39;, &#39;TTYWrap&#39; ]
//   After: [ &#39;TTYWrap&#39;, &#39;TTYWrap&#39;, &#39;TTYWrap&#39;, &#39;Timeout&#39; ]
</code></pre>
</section><section><h3><code>process.getegid()</code><span><a class="mark" href="#processgetegid" id="processgetegid">#</a></span><a aria-hidden="true" class="legacy" id="process_process_getegid"></a></h3>
<div class="api_metadata">
<span>Added in: v2.0.0</span>
</div><p>The <code>process.getegid()</code> method returns the numerical effective group identity
of the Node.js process. (See <a href="http://man7.org/linux/man-pages/man2/getegid.2.html"><code>getegid(2)</code></a>.)</p>
<pre><code class="language-mjs">import process from &#39;node:process&#39;;

if (process.getegid) {
  console.log(`Current gid: ${process.getegid()}`);
}
</code></pre>
<pre><code class="language-cjs">const process = require(&#39;node:process&#39;);

if (process.getegid) {
  console.log(`Current gid: ${process.getegid()}`);
}
</code></pre>
<p>This function is only available on POSIX platforms (i.e. not Windows or
Android).</p>
</section><section><h3><code>process.geteuid()</code><span><a class="mark" href="#processgeteuid" id="processgeteuid">#</a></span><a aria-hidden="true" class="legacy" id="process_process_geteuid"></a></h3>
<div class="api_metadata">
<span>Added in: v2.0.0</span>
</div><ul>
<li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type">&lt;Object&gt;</a></li>
</ul>
<p>The <code>process.geteuid()</code> method returns the numerical effective user identity of
the process. (See <a href="http://man7.org/linux/man-pages/man2/geteuid.2.html"><code>geteuid(2)</code></a>.)</p>
<pre><code class="language-mjs">import process from &#39;node:process&#39;;

if (process.geteuid) {
  console.log(`Current uid: ${process.geteuid()}`);
}
</code></pre>
<pre><code class="language-cjs">const process = require(&#39;node:process&#39;);

if (process.geteuid) {
  console.log(`Current uid: ${process.geteuid()}`);
}
</code></pre>
<p>This function is only available on POSIX platforms (i.e. not Windows or
Android).</p>
</section><section><h3><code>process.getgid()</code><span><a class="mark" href="#processgetgid" id="processgetgid">#</a></span><a aria-hidden="true" class="legacy" id="process_process_getgid"></a></h3>
<div class="api_metadata">
<span>Added in: v0.1.31</span>
</div><ul>
<li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type">&lt;Object&gt;</a></li>
</ul>
<p>The <code>process.getgid()</code> method returns the numerical group identity of the
process. (See <a href="http://man7.org/linux/man-pages/man2/getgid.2.html"><code>getgid(2)</code></a>.)</p>
<pre><code class="language-mjs">import process from &#39;node:process&#39;;

if (process.getgid) {
  console.log(`Current gid: ${process.getgid()}`);
}
</code></pre>
<pre><code class="language-cjs">const process = require(&#39;node:process&#39;);

if (process.getgid) {
  console.log(`Current gid: ${process.getgid()}`);
}
</code></pre>
<p>This function is only available on POSIX platforms (i.e. not Windows or
Android).</p>
</section><section><h3><code>process.getgroups()</code><span><a class="mark" href="#processgetgroups" id="processgetgroups">#</a></span><a aria-hidden="true" class="legacy" id="process_process_getgroups"></a></h3>
<div class="api_metadata">
<span>Added in: v0.9.4</span>
</div><ul>
<li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer[]&gt;</a></li>
</ul>
<p>The <code>process.getgroups()</code> method returns an array with the supplementary group
IDs. POSIX leaves it unspecified if the effective group ID is included but
Node.js ensures it always is.</p>
<pre><code class="language-mjs">import process from &#39;node:process&#39;;

if (process.getgroups) {
  console.log(process.getgroups()); // [ 16, 21, 297 ]
}
</code></pre>
<pre><code class="language-cjs">const process = require(&#39;node:process&#39;);

if (process.getgroups) {
  console.log(process.getgroups()); // [ 16, 21, 297 ]
}
</code></pre>
<p>This function is only available on POSIX platforms (i.e. not Windows or
Android).</p>
</section><section><h3><code>process.getuid()</code><span><a class="mark" href="#processgetuid" id="processgetuid">#</a></span><a aria-hidden="true" class="legacy" id="process_process_getuid"></a></h3>
<div class="api_metadata">
<span>Added in: v0.1.28</span>
</div><ul>
<li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer&gt;</a></li>
</ul>
<p>The <code>process.getuid()</code> method returns the numeric user identity of the process.
(See <a href="http://man7.org/linux/man-pages/man2/getuid.2.html"><code>getuid(2)</code></a>.)</p>
<pre><code class="language-mjs">import process from &#39;node:process&#39;;

if (process.getuid) {
  console.log(`Current uid: ${process.getuid()}`);
}
</code></pre>
<pre><code class="language-cjs">const process = require(&#39;node:process&#39;);

if (process.getuid) {
  console.log(`Current uid: ${process.getuid()}`);
}
</code></pre>
<p>This function is only available on POSIX platforms (i.e. not Windows or
Android).</p>
</section><section><h3><code>process.hasUncaughtExceptionCaptureCallback()</code><span><a class="mark" href="#processhasuncaughtexceptioncapturecallback" id="processhasuncaughtexceptioncapturecallback">#</a></span><a aria-hidden="true" class="legacy" id="process_process_hasuncaughtexceptioncapturecallback"></a></h3>
<div class="api_metadata">
<span>Added in: v9.3.0</span>
</div><ul>
<li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type" class="type">&lt;boolean&gt;</a></li>
</ul>
<p>Indicates whether a callback has been set using
<a href="#processsetuncaughtexceptioncapturecallbackfn"><code>process.setUncaughtExceptionCaptureCallback()</code></a>.</p>
</section><section><h3><code>process.hrtime([time])</code><span><a class="mark" href="#processhrtimetime" id="processhrtimetime">#</a></span><a aria-hidden="true" class="legacy" id="process_process_hrtime_time"></a></h3>
<div class="api_metadata">
<span>Added in: v0.7.6</span>
</div><blockquote>
<p>Stability: 3 - Legacy. Use <a href="#processhrtimebigint"><code>process.hrtime.bigint()</code></a> instead.</p>
</blockquote>
<ul>
<li><code>time</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer[]&gt;</a> The result of a previous call to <code>process.hrtime()</code></li>
<li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer[]&gt;</a></li>
</ul>
<p>This is the legacy version of <a href="#processhrtimebigint"><code>process.hrtime.bigint()</code></a>
before <code>bigint</code> was introduced in JavaScript.</p>
<p>The <code>process.hrtime()</code> method returns the current high-resolution real time
in a <code>[seconds, nanoseconds]</code> tuple <code>Array</code>, where <code>nanoseconds</code> is the
remaining part of the real time that can&#39;t be represented in second precision.</p>
<p><code>time</code> is an optional parameter that must be the result of a previous
<code>process.hrtime()</code> call to diff with the current time. If the parameter
passed in is not a tuple <code>Array</code>, a <code>TypeError</code> will be thrown. Passing in a
user-defined array instead of the result of a previous call to
<code>process.hrtime()</code> will lead to undefined behavior.</p>
<p>These times are relative to an arbitrary time in the
past, and not related to the time of day and therefore not subject to clock
drift. The primary use is for measuring performance between intervals:</p>
<pre><code class="language-mjs">import { hrtime } from &#39;node:process&#39;;

const NS_PER_SEC = 1e9;
const time = hrtime();
// [ 1800216, 25 ]

setTimeout(() =&gt; {
  const diff = hrtime(time);
  // [ 1, 552 ]

  console.log(`Benchmark took ${diff[0] * NS_PER_SEC + diff[1]} nanoseconds`);
  // Benchmark took 1000000552 nanoseconds
}, 1000);
</code></pre>
<pre><code class="language-cjs">const { hrtime } = require(&#39;node:process&#39;);

const NS_PER_SEC = 1e9;
const time = hrtime();
// [ 1800216, 25 ]

setTimeout(() =&gt; {
  const diff = hrtime(time);
  // [ 1, 552 ]

  console.log(`Benchmark took ${diff[0] * NS_PER_SEC + diff[1]} nanoseconds`);
  // Benchmark took 1000000552 nanoseconds
}, 1000);
</code></pre>
</section><section><h3><code>process.hrtime.bigint()</code><span><a class="mark" href="#processhrtimebigint" id="processhrtimebigint">#</a></span><a aria-hidden="true" class="legacy" id="process_process_hrtime_bigint"></a></h3>
<div class="api_metadata">
<span>Added in: v10.7.0</span>
</div><ul>
<li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt" class="type">&lt;bigint&gt;</a></li>
</ul>
<p>The <code>bigint</code> version of the <a href="#processhrtimetime"><code>process.hrtime()</code></a> method returning the
current high-resolution real time in nanoseconds as a <code>bigint</code>.</p>
<p>Unlike <a href="#processhrtimetime"><code>process.hrtime()</code></a>, it does not support an additional <code>time</code>
argument since the difference can just be computed directly
by subtraction of the two <code>bigint</code>s.</p>
<pre><code class="language-mjs">import { hrtime } from &#39;node:process&#39;;

const start = hrtime.bigint();
// 191051479007711n

setTimeout(() =&gt; {
  const end = hrtime.bigint();
  // 191052633396993n

  console.log(`Benchmark took ${end - start} nanoseconds`);
  // Benchmark took 1154389282 nanoseconds
}, 1000);
</code></pre>
<pre><code class="language-cjs">const { hrtime } = require(&#39;node:process&#39;);

const start = hrtime.bigint();
// 191051479007711n

setTimeout(() =&gt; {
  const end = hrtime.bigint();
  // 191052633396993n

  console.log(`Benchmark took ${end - start} nanoseconds`);
  // Benchmark took 1154389282 nanoseconds
}, 1000);
</code></pre>
</section><section><h3><code>process.initgroups(user, extraGroup)</code><span><a class="mark" href="#processinitgroupsuser-extragroup" id="processinitgroupsuser-extragroup">#</a></span><a aria-hidden="true" class="legacy" id="process_process_initgroups_user_extragroup"></a></h3>
<div class="api_metadata">
<span>Added in: v0.9.4</span>
</div><ul>
<li><code>user</code> {string|number} The user name or numeric identifier.</li>
<li><code>extraGroup</code> {string|number} A group name or numeric identifier.</li>
</ul>
<p>The <code>process.initgroups()</code> method reads the <code>/etc/group</code> file and initializes
the group access list, using all groups of which the user is a member. This is
a privileged operation that requires that the Node.js process either have <code>root</code>
access or the <code>CAP_SETGID</code> capability.</p>
<p>Use care when dropping privileges:</p>
<pre><code class="language-mjs">import { getgroups, initgroups, setgid } from &#39;node:process&#39;;

console.log(getgroups());         // [ 0 ]
initgroups(&#39;nodeuser&#39;, 1000);     // switch user
console.log(getgroups());         // [ 27, 30, 46, 1000, 0 ]
setgid(1000);                     // drop root gid
console.log(getgroups());         // [ 27, 30, 46, 1000 ]
</code></pre>
<pre><code class="language-cjs">const { getgroups, initgroups, setgid } = require(&#39;node:process&#39;);

console.log(getgroups());         // [ 0 ]
initgroups(&#39;nodeuser&#39;, 1000);     // switch user
console.log(getgroups());         // [ 27, 30, 46, 1000, 0 ]
setgid(1000);                     // drop root gid
console.log(getgroups());         // [ 27, 30, 46, 1000 ]
</code></pre>
<p>This function is only available on POSIX platforms (i.e. not Windows or
Android).
This feature is not available in <a href="worker_threads.html#class-worker"><code>Worker</code></a> threads.</p>
</section><section><h3><code>process.kill(pid[, signal])</code><span><a class="mark" href="#processkillpid-signal" id="processkillpid-signal">#</a></span><a aria-hidden="true" class="legacy" id="process_process_kill_pid_signal"></a></h3>
<div class="api_metadata">
<span>Added in: v0.0.6</span>
</div><ul>
<li><code>pid</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;number&gt;</a> A process ID</li>
<li><code>signal</code> {string|number} The signal to send, either as a string or number.
<strong>Default:</strong> <code>&#39;SIGTERM&#39;</code>.</li>
</ul>
<p>The <code>process.kill()</code> method sends the <code>signal</code> to the process identified by
<code>pid</code>.</p>
<p>Signal names are strings such as <code>&#39;SIGINT&#39;</code> or <code>&#39;SIGHUP&#39;</code>. See <a href="#signal-events">Signal Events</a>
and <a href="http://man7.org/linux/man-pages/man2/kill.2.html"><code>kill(2)</code></a> for more information.</p>
<p>This method will throw an error if the target <code>pid</code> does not exist. As a special
case, a signal of <code>0</code> can be used to test for the existence of a process.
Windows platforms will throw an error if the <code>pid</code> is used to kill a process
group.</p>
<p>Even though the name of this function is <code>process.kill()</code>, it is really just a
signal sender, like the <code>kill</code> system call. The signal sent may do something
other than kill the target process.</p>
<pre><code class="language-mjs">import process, { kill } from &#39;node:process&#39;;

process.on(&#39;SIGHUP&#39;, () =&gt; {
  console.log(&#39;Got SIGHUP signal.&#39;);
});

setTimeout(() =&gt; {
  console.log(&#39;Exiting.&#39;);
  process.exit(0);
}, 100);

kill(process.pid, &#39;SIGHUP&#39;);
</code></pre>
<pre><code class="language-cjs">const process = require(&#39;node:process&#39;);

process.on(&#39;SIGHUP&#39;, () =&gt; {
  console.log(&#39;Got SIGHUP signal.&#39;);
});

setTimeout(() =&gt; {
  console.log(&#39;Exiting.&#39;);
  process.exit(0);
}, 100);

process.kill(process.pid, &#39;SIGHUP&#39;);
</code></pre>
<p>When <code>SIGUSR1</code> is received by a Node.js process, Node.js will start the
debugger. See <a href="#signal-events">Signal Events</a>.</p>
</section><section><h3><code>process.mainModule</code><span><a class="mark" href="#processmainmodule" id="processmainmodule">#</a></span><a aria-hidden="true" class="legacy" id="process_process_mainmodule"></a></h3>
<div class="api_metadata">
<span>Added in: v0.1.17</span><span>Deprecated since: v14.0.0</span>
</div><blockquote>
<p>Stability: 0 - Deprecated: Use <a href="modules.html#accessing-the-main-module"><code>require.main</code></a> instead.</p>
</blockquote>
<ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type">&lt;Object&gt;</a></li>
</ul>
<p>The <code>process.mainModule</code> property provides an alternative way of retrieving
<a href="modules.html#accessing-the-main-module"><code>require.main</code></a>. The difference is that if the main module changes at
runtime, <a href="modules.html#accessing-the-main-module"><code>require.main</code></a> may still refer to the original main module in
modules that were required before the change occurred. Generally, it&#39;s
safe to assume that the two refer to the same module.</p>
<p>As with <a href="modules.html#accessing-the-main-module"><code>require.main</code></a>, <code>process.mainModule</code> will be <code>undefined</code> if there
is no entry script.</p>
</section><section><h3><code>process.memoryUsage()</code><span><a class="mark" href="#processmemoryusage" id="processmemoryusage">#</a></span><a aria-hidden="true" class="legacy" id="process_process_memoryusage"></a></h3>
<div class="api_metadata">
<details class="changelog"><summary>History</summary>
<table>
<tr><th>Version</th><th>Changes</th></tr>
<tr><td>v13.9.0, v12.17.0</td>
<td><p>Added <code>arrayBuffers</code> to the returned object.</p>
</td></tr>
<tr><td>v7.2.0</td>
<td><p>Added <code>external</code> to the returned object.</p>
</td></tr>
<tr><td>v0.1.16</td>
<td><p><span>Added in: v0.1.16</span></p>
</td></tr>
</table>
</details>
</div><ul>
<li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type">&lt;Object&gt;</a><ul>
<li><code>rss</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer&gt;</a></li>
<li><code>heapTotal</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer&gt;</a></li>
<li><code>heapUsed</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer&gt;</a></li>
<li><code>external</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer&gt;</a></li>
<li><code>arrayBuffers</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer&gt;</a></li>
</ul>
</li>
</ul>
<p>Returns an object describing the memory usage of the Node.js process measured in
bytes.</p>
<pre><code class="language-mjs">import { memoryUsage } from &#39;node:process&#39;;

console.log(memoryUsage());
// Prints:
// {
//  rss: 4935680,
//  heapTotal: 1826816,
//  heapUsed: 650472,
//  external: 49879,
//  arrayBuffers: 9386
// }
</code></pre>
<pre><code class="language-cjs">const { memoryUsage } = require(&#39;node:process&#39;);

console.log(memoryUsage());
// Prints:
// {
//  rss: 4935680,
//  heapTotal: 1826816,
//  heapUsed: 650472,
//  external: 49879,
//  arrayBuffers: 9386
// }
</code></pre>
<ul>
<li><code>heapTotal</code> and <code>heapUsed</code> refer to V8&#39;s memory usage.</li>
<li><code>external</code> refers to the memory usage of C++ objects bound to JavaScript
objects managed by V8.</li>
<li><code>rss</code>, Resident Set Size, is the amount of space occupied in the main
memory device (that is a subset of the total allocated memory) for the
process, including all C++ and JavaScript objects and code.</li>
<li><code>arrayBuffers</code> refers to memory allocated for <code>ArrayBuffer</code>s and
<code>SharedArrayBuffer</code>s, including all Node.js <a href="buffer.html"><code>Buffer</code></a>s.
This is also included in the <code>external</code> value. When Node.js is used as an
embedded library, this value may be <code>0</code> because allocations for <code>ArrayBuffer</code>s
may not be tracked in that case.</li>
</ul>
<p>When using <a href="worker_threads.html#class-worker"><code>Worker</code></a> threads, <code>rss</code> will be a value that is valid for the
entire process, while the other fields will only refer to the current thread.</p>
<p>The <code>process.memoryUsage()</code> method iterates over each page to gather
information about memory usage which might be slow depending on the
program memory allocations.</p>
</section><section><h3><code>process.memoryUsage.rss()</code><span><a class="mark" href="#processmemoryusagerss" id="processmemoryusagerss">#</a></span><a aria-hidden="true" class="legacy" id="process_process_memoryusage_rss"></a></h3>
<div class="api_metadata">
<span>Added in: v15.6.0, v14.18.0</span>
</div><ul>
<li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer&gt;</a></li>
</ul>
<p>The <code>process.memoryUsage.rss()</code> method returns an integer representing the
Resident Set Size (RSS) in bytes.</p>
<p>The Resident Set Size, is the amount of space occupied in the main
memory device (that is a subset of the total allocated memory) for the
process, including all C++ and JavaScript objects and code.</p>
<p>This is the same value as the <code>rss</code> property provided by <code>process.memoryUsage()</code>
but <code>process.memoryUsage.rss()</code> is faster.</p>
<pre><code class="language-mjs">import { memoryUsage } from &#39;node:process&#39;;

console.log(memoryUsage.rss());
// 35655680
</code></pre>
<pre><code class="language-cjs">const { memoryUsage } = require(&#39;node:process&#39;);

console.log(memoryUsage.rss());
// 35655680
</code></pre>
</section><section><h3><code>process.nextTick(callback[, ...args])</code><span><a class="mark" href="#processnexttickcallback-args" id="processnexttickcallback-args">#</a></span><a aria-hidden="true" class="legacy" id="process_process_nexttick_callback_args"></a></h3>
<div class="api_metadata">
<details class="changelog"><summary>History</summary>
<table>
<tr><th>Version</th><th>Changes</th></tr>
<tr><td>v18.0.0</td>
<td><p>Passing an invalid callback to the <code>callback</code> argument now throws <code>ERR_INVALID_ARG_TYPE</code> instead of <code>ERR_INVALID_CALLBACK</code>.</p>
</td></tr>
<tr><td>v1.8.1</td>
<td><p>Additional arguments after <code>callback</code> are now supported.</p>
</td></tr>
<tr><td>v0.1.26</td>
<td><p><span>Added in: v0.1.26</span></p>
</td></tr>
</table>
</details>
</div><ul>
<li><code>callback</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function" class="type">&lt;Function&gt;</a></li>
<li><code>...args</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types" class="type">&lt;any&gt;</a> Additional arguments to pass when invoking the <code>callback</code></li>
</ul>
<p><code>process.nextTick()</code> adds <code>callback</code> to the &quot;next tick queue&quot;. This queue is
fully drained after the current operation on the JavaScript stack runs to
completion and before the event loop is allowed to continue. It&#39;s possible to
create an infinite loop if one were to recursively call <code>process.nextTick()</code>.
See the <a href="https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/#process-nexttick">Event Loop</a> guide for more background.</p>
<pre><code class="language-mjs">import { nextTick } from &#39;node:process&#39;;

console.log(&#39;start&#39;);
nextTick(() =&gt; {
  console.log(&#39;nextTick callback&#39;);
});
console.log(&#39;scheduled&#39;);
// Output:
// start
// scheduled
// nextTick callback
</code></pre>
<pre><code class="language-cjs">const { nextTick } = require(&#39;node:process&#39;);

console.log(&#39;start&#39;);
nextTick(() =&gt; {
  console.log(&#39;nextTick callback&#39;);
});
console.log(&#39;scheduled&#39;);
// Output:
// start
// scheduled
// nextTick callback
</code></pre>
<p>This is important when developing APIs in order to give users the opportunity
to assign event handlers <em>after</em> an object has been constructed but before any
I/O has occurred:</p>
<pre><code class="language-mjs">import { nextTick } from &#39;node:process&#39;;

function MyThing(options) {
  this.setupOptions(options);

  nextTick(() =&gt; {
    this.startDoingStuff();
  });
}

const thing = new MyThing();
thing.getReadyForStuff();

// thing.startDoingStuff() gets called now, not before.
</code></pre>
<pre><code class="language-cjs">const { nextTick } = require(&#39;node:process&#39;);

function MyThing(options) {
  this.setupOptions(options);

  nextTick(() =&gt; {
    this.startDoingStuff();
  });
}

const thing = new MyThing();
thing.getReadyForStuff();

// thing.startDoingStuff() gets called now, not before.
</code></pre>
<p>It is very important for APIs to be either 100% synchronous or 100%
asynchronous. Consider this example:</p>
<pre><code class="language-js">// WARNING!  DO NOT USE!  BAD UNSAFE HAZARD!
function maybeSync(arg, cb) {
  if (arg) {
    cb();
    return;
  }

  fs.stat(&#39;file&#39;, cb);
}
</code></pre>
<p>This API is hazardous because in the following case:</p>
<pre><code class="language-js">const maybeTrue = Math.random() &gt; 0.5;

maybeSync(maybeTrue, () =&gt; {
  foo();
});

bar();
</code></pre>
<p>It is not clear whether <code>foo()</code> or <code>bar()</code> will be called first.</p>
<p>The following approach is much better:</p>
<pre><code class="language-mjs">import { nextTick } from &#39;node:process&#39;;

function definitelyAsync(arg, cb) {
  if (arg) {
    nextTick(cb);
    return;
  }

  fs.stat(&#39;file&#39;, cb);
}
</code></pre>
<pre><code class="language-cjs">const { nextTick } = require(&#39;node:process&#39;);

function definitelyAsync(arg, cb) {
  if (arg) {
    nextTick(cb);
    return;
  }

  fs.stat(&#39;file&#39;, cb);
}
</code></pre>
<h4>When to use <code>queueMicrotask()</code> vs. <code>process.nextTick()</code><span><a class="mark" href="#when-to-use-queuemicrotask-vs-processnexttick" id="when-to-use-queuemicrotask-vs-processnexttick">#</a></span><a aria-hidden="true" class="legacy" id="process_when_to_use_queuemicrotask_vs_process_nexttick"></a></h4>
<p>The <a href="globals.html#queuemicrotaskcallback"><code>queueMicrotask()</code></a> API is an alternative to <code>process.nextTick()</code> that
also defers execution of a function using the same microtask queue used to
execute the then, catch, and finally handlers of resolved promises. Within
Node.js, every time the &quot;next tick queue&quot; is drained, the microtask queue
is drained immediately after.</p>
<pre><code class="language-mjs">import { nextTick } from &#39;node:process&#39;;

Promise.resolve().then(() =&gt; console.log(2));
queueMicrotask(() =&gt; console.log(3));
nextTick(() =&gt; console.log(1));
// Output:
// 1
// 2
// 3
</code></pre>
<pre><code class="language-cjs">const { nextTick } = require(&#39;node:process&#39;);

Promise.resolve().then(() =&gt; console.log(2));
queueMicrotask(() =&gt; console.log(3));
nextTick(() =&gt; console.log(1));
// Output:
// 1
// 2
// 3
</code></pre>
<p>For <em>most</em> userland use cases, the <code>queueMicrotask()</code> API provides a portable
and reliable mechanism for deferring execution that works across multiple
JavaScript platform environments and should be favored over <code>process.nextTick()</code>.
In simple scenarios, <code>queueMicrotask()</code> can be a drop-in replacement for
<code>process.nextTick()</code>.</p>
<pre><code class="language-js">console.log(&#39;start&#39;);
queueMicrotask(() =&gt; {
  console.log(&#39;microtask callback&#39;);
});
console.log(&#39;scheduled&#39;);
// Output:
// start
// scheduled
// microtask callback
</code></pre>
<p>One note-worthy difference between the two APIs is that <code>process.nextTick()</code>
allows specifying additional values that will be passed as arguments to the
deferred function when it is called. Achieving the same result with
<code>queueMicrotask()</code> requires using either a closure or a bound function:</p>
<pre><code class="language-js">function deferred(a, b) {
  console.log(&#39;microtask&#39;, a + b);
}

console.log(&#39;start&#39;);
queueMicrotask(deferred.bind(undefined, 1, 2));
console.log(&#39;scheduled&#39;);
// Output:
// start
// scheduled
// microtask 3
</code></pre>
<p>There are minor differences in the way errors raised from within the next tick
queue and microtask queue are handled. Errors thrown within a queued microtask
callback should be handled within the queued callback when possible. If they are
not, the <code>process.on(&#39;uncaughtException&#39;)</code> event handler can be used to capture
and handle the errors.</p>
<p>When in doubt, unless the specific capabilities of <code>process.nextTick()</code> are
needed, use <code>queueMicrotask()</code>.</p>
</section><section><h3><code>process.noDeprecation</code><span><a class="mark" href="#processnodeprecation" id="processnodeprecation">#</a></span><a aria-hidden="true" class="legacy" id="process_process_nodeprecation"></a></h3>
<div class="api_metadata">
<span>Added in: v0.8.0</span>
</div><ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type" class="type">&lt;boolean&gt;</a></li>
</ul>
<p>The <code>process.noDeprecation</code> property indicates whether the <code>--no-deprecation</code>
flag is set on the current Node.js process. See the documentation for
the <a href="#event-warning"><code>&#39;warning&#39;</code> event</a> and the
<a href="#processemitwarningwarning-type-code-ctor"><code>emitWarning()</code> method</a> for more information about this
flag&#39;s behavior.</p>
</section><section><h3><code>process.pid</code><span><a class="mark" href="#processpid" id="processpid">#</a></span><a aria-hidden="true" class="legacy" id="process_process_pid"></a></h3>
<div class="api_metadata">
<span>Added in: v0.1.15</span>
</div><ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer&gt;</a></li>
</ul>
<p>The <code>process.pid</code> property returns the PID of the process.</p>
<pre><code class="language-mjs">import { pid } from &#39;node:process&#39;;

console.log(`This process is pid ${pid}`);
</code></pre>
<pre><code class="language-cjs">const { pid } = require(&#39;node:process&#39;);

console.log(`This process is pid ${pid}`);
</code></pre>
</section><section><h3><code>process.platform</code><span><a class="mark" href="#processplatform" id="processplatform">#</a></span><a aria-hidden="true" class="legacy" id="process_process_platform"></a></h3>
<div class="api_metadata">
<span>Added in: v0.1.16</span>
</div><ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a></li>
</ul>
<p>The <code>process.platform</code> property returns a string identifying the operating
system platform for which the Node.js binary was compiled.</p>
<p>Currently possible values are:</p>
<ul>
<li><code>&#39;aix&#39;</code></li>
<li><code>&#39;darwin&#39;</code></li>
<li><code>&#39;freebsd&#39;</code></li>
<li><code>&#39;linux&#39;</code></li>
<li><code>&#39;openbsd&#39;</code></li>
<li><code>&#39;sunos&#39;</code></li>
<li><code>&#39;win32&#39;</code></li>
</ul>
<pre><code class="language-mjs">import { platform } from &#39;node:process&#39;;

console.log(`This platform is ${platform}`);
</code></pre>
<pre><code class="language-cjs">const { platform } = require(&#39;node:process&#39;);

console.log(`This platform is ${platform}`);
</code></pre>
<p>The value <code>&#39;android&#39;</code> may also be returned if the Node.js is built on the
Android operating system. However, Android support in Node.js
<a href="https://github.com/nodejs/node/blob/HEAD/BUILDING.md#androidandroid-based-devices-eg-firefox-os">is experimental</a>.</p>
</section><section><h3><code>process.ppid</code><span><a class="mark" href="#processppid" id="processppid">#</a></span><a aria-hidden="true" class="legacy" id="process_process_ppid"></a></h3>
<div class="api_metadata">
<span>Added in: v9.2.0, v8.10.0, v6.13.0</span>
</div><ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer&gt;</a></li>
</ul>
<p>The <code>process.ppid</code> property returns the PID of the parent of the
current process.</p>
<pre><code class="language-mjs">import { ppid } from &#39;node:process&#39;;

console.log(`The parent process is pid ${ppid}`);
</code></pre>
<pre><code class="language-cjs">const { ppid } = require(&#39;node:process&#39;);

console.log(`The parent process is pid ${ppid}`);
</code></pre>
</section><section><h3><code>process.release</code><span><a class="mark" href="#processrelease" id="processrelease">#</a></span><a aria-hidden="true" class="legacy" id="process_process_release"></a></h3>
<div class="api_metadata">
<details class="changelog"><summary>History</summary>
<table>
<tr><th>Version</th><th>Changes</th></tr>
<tr><td>v4.2.0</td>
<td><p>The <code>lts</code> property is now supported.</p>
</td></tr>
<tr><td>v3.0.0</td>
<td><p><span>Added in: v3.0.0</span></p>
</td></tr>
</table>
</details>
</div><ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type">&lt;Object&gt;</a></li>
</ul>
<p>The <code>process.release</code> property returns an <code>Object</code> containing metadata related
to the current release, including URLs for the source tarball and headers-only
tarball.</p>
<p><code>process.release</code> contains the following properties:</p>
<ul>
<li><code>name</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> A value that will always be <code>&#39;node&#39;</code>.</li>
<li><code>sourceUrl</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> an absolute URL pointing to a <em><code>.tar.gz</code></em> file containing
the source code of the current release.</li>
<li><code>headersUrl</code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> an absolute URL pointing to a <em><code>.tar.gz</code></em> file containing
only the source header files for the current release. This file is
significantly smaller than the full source file and can be used for compiling
Node.js native add-ons.</li>
<li><code>libUrl</code> {string|undefined} an absolute URL pointing to a <em><code>node.lib</code></em> file
matching the architecture and version of the current release. This file is
used for compiling Node.js native add-ons. <em>This property is only present on
Windows builds of Node.js and will be missing on all other platforms.</em></li>
<li><code>lts</code> {string|undefined} a string label identifying the <a href="https://github.com/nodejs/Release">LTS</a> label for this
release. This property only exists for LTS releases and is <code>undefined</code> for all
other release types, including <em>Current</em> releases. Valid values include the
LTS Release code names (including those that are no longer supported).<ul>
<li><code>&#39;Fermium&#39;</code> for the 14.x LTS line beginning with 14.15.0.</li>
<li><code>&#39;Gallium&#39;</code> for the 16.x LTS line beginning with 16.13.0.</li>
<li><code>&#39;Hydrogen&#39;</code> for the 18.x LTS line beginning with 18.12.0.
For other LTS Release code names, see <a href="https://github.com/nodejs/node/blob/HEAD/doc/changelogs/CHANGELOG_ARCHIVE.md">Node.js Changelog Archive</a></li>
</ul>
</li>
</ul>
<!-- eslint-skip -->

<pre><code class="language-js">{
  name: &#39;node&#39;,
  lts: &#39;Hydrogen&#39;,
  sourceUrl: &#39;https://nodejs.org/download/release/v18.12.0/node-v18.12.0.tar.gz&#39;,
  headersUrl: &#39;https://nodejs.org/download/release/v18.12.0/node-v18.12.0-headers.tar.gz&#39;,
  libUrl: &#39;https://nodejs.org/download/release/v18.12.0/win-x64/node.lib&#39;
}
</code></pre>
<p>In custom builds from non-release versions of the source tree, only the
<code>name</code> property may be present. The additional properties should not be
relied upon to exist.</p>
</section><section><h3><code>process.report</code><span><a class="mark" href="#processreport" id="processreport">#</a></span><a aria-hidden="true" class="legacy" id="process_process_report"></a></h3>
<div class="api_metadata">
<details class="changelog"><summary>History</summary>
<table>
<tr><th>Version</th><th>Changes</th></tr>
<tr><td>v13.12.0, v12.17.0</td>
<td><p>This API is no longer experimental.</p>
</td></tr>
<tr><td>v11.8.0</td>
<td><p><span>Added in: v11.8.0</span></p>
</td></tr>
</table>
</details>
</div><ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type">&lt;Object&gt;</a></li>
</ul>
<p><code>process.report</code> is an object whose methods are used to generate diagnostic
reports for the current process. Additional documentation is available in the
<a href="report.html">report documentation</a>.</p>
<h4><code>process.report.compact</code><span><a class="mark" href="#processreportcompact" id="processreportcompact">#</a></span><a aria-hidden="true" class="legacy" id="process_process_report_compact"></a></h4>
<div class="api_metadata">
<span>Added in: v13.12.0, v12.17.0</span>
</div><ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type" class="type">&lt;boolean&gt;</a></li>
</ul>
<p>Write reports in a compact format, single-line JSON, more easily consumable
by log processing systems than the default multi-line format designed for
human consumption.</p>
<pre><code class="language-mjs">import { report } from &#39;node:process&#39;;

console.log(`Reports are compact? ${report.compact}`);
</code></pre>
<pre><code class="language-cjs">const { report } = require(&#39;node:process&#39;);

console.log(`Reports are compact? ${report.compact}`);
</code></pre>
<h4><code>process.report.directory</code><span><a class="mark" href="#processreportdirectory" id="processreportdirectory">#</a></span><a aria-hidden="true" class="legacy" id="process_process_report_directory"></a></h4>
<div class="api_metadata">
<details class="changelog"><summary>History</summary>
<table>
<tr><th>Version</th><th>Changes</th></tr>
<tr><td>v13.12.0, v12.17.0</td>
<td><p>This API is no longer experimental.</p>
</td></tr>
<tr><td>v11.12.0</td>
<td><p><span>Added in: v11.12.0</span></p>
</td></tr>
</table>
</details>
</div><ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a></li>
</ul>
<p>Directory where the report is written. The default value is the empty string,
indicating that reports are written to the current working directory of the
Node.js process.</p>
<pre><code class="language-mjs">import { report } from &#39;node:process&#39;;

console.log(`Report directory is ${report.directory}`);
</code></pre>
<pre><code class="language-cjs">const { report } = require(&#39;node:process&#39;);

console.log(`Report directory is ${report.directory}`);
</code></pre>
<h4><code>process.report.filename</code><span><a class="mark" href="#processreportfilename" id="processreportfilename">#</a></span><a aria-hidden="true" class="legacy" id="process_process_report_filename"></a></h4>
<div class="api_metadata">
<details class="changelog"><summary>History</summary>
<table>
<tr><th>Version</th><th>Changes</th></tr>
<tr><td>v13.12.0, v12.17.0</td>
<td><p>This API is no longer experimental.</p>
</td></tr>
<tr><td>v11.12.0</td>
<td><p><span>Added in: v11.12.0</span></p>
</td></tr>
</table>
</details>
</div><ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a></li>
</ul>
<p>Filename where the report is written. If set to the empty string, the output
filename will be comprised of a timestamp, PID, and sequence number. The default
value is the empty string.</p>
<p>If the value of <code>process.report.filename</code> is set to <code>&#39;stdout&#39;</code> or <code>&#39;stderr&#39;</code>,
the report is written to the stdout or stderr of the process respectively.</p>
<pre><code class="language-mjs">import { report } from &#39;node:process&#39;;

console.log(`Report filename is ${report.filename}`);
</code></pre>
<pre><code class="language-cjs">const { report } = require(&#39;node:process&#39;);

console.log(`Report filename is ${report.filename}`);
</code></pre>
<h4><code>process.report.getReport([err])</code><span><a class="mark" href="#processreportgetreporterr" id="processreportgetreporterr">#</a></span><a aria-hidden="true" class="legacy" id="process_process_report_getreport_err"></a></h4>
<div class="api_metadata">
<details class="changelog"><summary>History</summary>
<table>
<tr><th>Version</th><th>Changes</th></tr>
<tr><td>v13.12.0, v12.17.0</td>
<td><p>This API is no longer experimental.</p>
</td></tr>
<tr><td>v11.8.0</td>
<td><p><span>Added in: v11.8.0</span></p>
</td></tr>
</table>
</details>
</div><ul>
<li><code>err</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error" class="type">&lt;Error&gt;</a> A custom error used for reporting the JavaScript stack.</li>
<li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type">&lt;Object&gt;</a></li>
</ul>
<p>Returns a JavaScript Object representation of a diagnostic report for the
running process. The report&#39;s JavaScript stack trace is taken from <code>err</code>, if
present.</p>
<pre><code class="language-mjs">import { report } from &#39;node:process&#39;;
import util from &#39;node:util&#39;;

const data = report.getReport();
console.log(data.header.nodejsVersion);

// Similar to process.report.writeReport()
import fs from &#39;node:fs&#39;;
fs.writeFileSync(&#39;my-report.log&#39;, util.inspect(data), &#39;utf8&#39;);
</code></pre>
<pre><code class="language-cjs">const { report } = require(&#39;node:process&#39;);
const util = require(&#39;node:util&#39;);

const data = report.getReport();
console.log(data.header.nodejsVersion);

// Similar to process.report.writeReport()
const fs = require(&#39;node:fs&#39;);
fs.writeFileSync(&#39;my-report.log&#39;, util.inspect(data), &#39;utf8&#39;);
</code></pre>
<p>Additional documentation is available in the <a href="report.html">report documentation</a>.</p>
<h4><code>process.report.reportOnFatalError</code><span><a class="mark" href="#processreportreportonfatalerror" id="processreportreportonfatalerror">#</a></span><a aria-hidden="true" class="legacy" id="process_process_report_reportonfatalerror"></a></h4>
<div class="api_metadata">
<details class="changelog"><summary>History</summary>
<table>
<tr><th>Version</th><th>Changes</th></tr>
<tr><td>v15.0.0, v14.17.0</td>
<td><p>This API is no longer experimental.</p>
</td></tr>
<tr><td>v11.12.0</td>
<td><p><span>Added in: v11.12.0</span></p>
</td></tr>
</table>
</details>
</div><ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type" class="type">&lt;boolean&gt;</a></li>
</ul>
<p>If <code>true</code>, a diagnostic report is generated on fatal errors, such as out of
memory errors or failed C++ assertions.</p>
<pre><code class="language-mjs">import { report } from &#39;node:process&#39;;

console.log(`Report on fatal error: ${report.reportOnFatalError}`);
</code></pre>
<pre><code class="language-cjs">const { report } = require(&#39;node:process&#39;);

console.log(`Report on fatal error: ${report.reportOnFatalError}`);
</code></pre>
<h4><code>process.report.reportOnSignal</code><span><a class="mark" href="#processreportreportonsignal" id="processreportreportonsignal">#</a></span><a aria-hidden="true" class="legacy" id="process_process_report_reportonsignal"></a></h4>
<div class="api_metadata">
<details class="changelog"><summary>History</summary>
<table>
<tr><th>Version</th><th>Changes</th></tr>
<tr><td>v13.12.0, v12.17.0</td>
<td><p>This API is no longer experimental.</p>
</td></tr>
<tr><td>v11.12.0</td>
<td><p><span>Added in: v11.12.0</span></p>
</td></tr>
</table>
</details>
</div><ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type" class="type">&lt;boolean&gt;</a></li>
</ul>
<p>If <code>true</code>, a diagnostic report is generated when the process receives the
signal specified by <code>process.report.signal</code>.</p>
<pre><code class="language-mjs">import { report } from &#39;node:process&#39;;

console.log(`Report on signal: ${report.reportOnSignal}`);
</code></pre>
<pre><code class="language-cjs">const { report } = require(&#39;node:process&#39;);

console.log(`Report on signal: ${report.reportOnSignal}`);
</code></pre>
<h4><code>process.report.reportOnUncaughtException</code><span><a class="mark" href="#processreportreportonuncaughtexception" id="processreportreportonuncaughtexception">#</a></span><a aria-hidden="true" class="legacy" id="process_process_report_reportonuncaughtexception"></a></h4>
<div class="api_metadata">
<details class="changelog"><summary>History</summary>
<table>
<tr><th>Version</th><th>Changes</th></tr>
<tr><td>v13.12.0, v12.17.0</td>
<td><p>This API is no longer experimental.</p>
</td></tr>
<tr><td>v11.12.0</td>
<td><p><span>Added in: v11.12.0</span></p>
</td></tr>
</table>
</details>
</div><ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type" class="type">&lt;boolean&gt;</a></li>
</ul>
<p>If <code>true</code>, a diagnostic report is generated on uncaught exception.</p>
<pre><code class="language-mjs">import { report } from &#39;node:process&#39;;

console.log(`Report on exception: ${report.reportOnUncaughtException}`);
</code></pre>
<pre><code class="language-cjs">const { report } = require(&#39;node:process&#39;);

console.log(`Report on exception: ${report.reportOnUncaughtException}`);
</code></pre>
<h4><code>process.report.signal</code><span><a class="mark" href="#processreportsignal" id="processreportsignal">#</a></span><a aria-hidden="true" class="legacy" id="process_process_report_signal"></a></h4>
<div class="api_metadata">
<details class="changelog"><summary>History</summary>
<table>
<tr><th>Version</th><th>Changes</th></tr>
<tr><td>v13.12.0, v12.17.0</td>
<td><p>This API is no longer experimental.</p>
</td></tr>
<tr><td>v11.12.0</td>
<td><p><span>Added in: v11.12.0</span></p>
</td></tr>
</table>
</details>
</div><ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a></li>
</ul>
<p>The signal used to trigger the creation of a diagnostic report. Defaults to
<code>&#39;SIGUSR2&#39;</code>.</p>
<pre><code class="language-mjs">import { report } from &#39;node:process&#39;;

console.log(`Report signal: ${report.signal}`);
</code></pre>
<pre><code class="language-cjs">const { report } = require(&#39;node:process&#39;);

console.log(`Report signal: ${report.signal}`);
</code></pre>
<h4><code>process.report.writeReport([filename][, err])</code><span><a class="mark" href="#processreportwritereportfilename-err" id="processreportwritereportfilename-err">#</a></span><a aria-hidden="true" class="legacy" id="process_process_report_writereport_filename_err"></a></h4>
<div class="api_metadata">
<details class="changelog"><summary>History</summary>
<table>
<tr><th>Version</th><th>Changes</th></tr>
<tr><td>v13.12.0, v12.17.0</td>
<td><p>This API is no longer experimental.</p>
</td></tr>
<tr><td>v11.8.0</td>
<td><p><span>Added in: v11.8.0</span></p>
</td></tr>
</table>
</details>
</div><ul>
<li><p><code>filename</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> Name of the file where the report is written. This
should be a relative path, that will be appended to the directory specified in
<code>process.report.directory</code>, or the current working directory of the Node.js
process, if unspecified.</p>
</li>
<li><p><code>err</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error" class="type">&lt;Error&gt;</a> A custom error used for reporting the JavaScript stack.</p>
</li>
<li><p>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> Returns the filename of the generated report.</p>
</li>
</ul>
<p>Writes a diagnostic report to a file. If <code>filename</code> is not provided, the default
filename includes the date, time, PID, and a sequence number. The report&#39;s
JavaScript stack trace is taken from <code>err</code>, if present.</p>
<p>If the value of <code>filename</code> is set to <code>&#39;stdout&#39;</code> or <code>&#39;stderr&#39;</code>, the report is
written to the stdout or stderr of the process respectively.</p>
<pre><code class="language-mjs">import { report } from &#39;node:process&#39;;

report.writeReport();
</code></pre>
<pre><code class="language-cjs">const { report } = require(&#39;node:process&#39;);

report.writeReport();
</code></pre>
<p>Additional documentation is available in the <a href="report.html">report documentation</a>.</p>
</section><section><h3><code>process.resourceUsage()</code><span><a class="mark" href="#processresourceusage" id="processresourceusage">#</a></span><a aria-hidden="true" class="legacy" id="process_process_resourceusage"></a></h3>
<div class="api_metadata">
<span>Added in: v12.6.0</span>
</div><ul>
<li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type">&lt;Object&gt;</a> the resource usage for the current process. All of these
values come from the <code>uv_getrusage</code> call which returns
a <a href="https://docs.libuv.org/en/v1.x/misc.html#c.uv_rusage_t"><code>uv_rusage_t</code> struct</a>.<ul>
<li><code>userCPUTime</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer&gt;</a> maps to <code>ru_utime</code> computed in microseconds.
It is the same value as <a href="#processcpuusagepreviousvalue"><code>process.cpuUsage().user</code></a>.</li>
<li><code>systemCPUTime</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer&gt;</a> maps to <code>ru_stime</code> computed in microseconds.
It is the same value as <a href="#processcpuusagepreviousvalue"><code>process.cpuUsage().system</code></a>.</li>
<li><code>maxRSS</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer&gt;</a> maps to <code>ru_maxrss</code> which is the maximum resident set
size used in kilobytes.</li>
<li><code>sharedMemorySize</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer&gt;</a> maps to <code>ru_ixrss</code> but is not supported by
any platform.</li>
<li><code>unsharedDataSize</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer&gt;</a> maps to <code>ru_idrss</code> but is not supported by
any platform.</li>
<li><code>unsharedStackSize</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer&gt;</a> maps to <code>ru_isrss</code> but is not supported by
any platform.</li>
<li><code>minorPageFault</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer&gt;</a> maps to <code>ru_minflt</code> which is the number of
minor page faults for the process, see
<a href="https://en.wikipedia.org/wiki/Page_fault#Minor">this article for more details</a>.</li>
<li><code>majorPageFault</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer&gt;</a> maps to <code>ru_majflt</code> which is the number of
major page faults for the process, see
<a href="https://en.wikipedia.org/wiki/Page_fault#Major">this article for more details</a>. This field is not
supported on Windows.</li>
<li><code>swappedOut</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer&gt;</a> maps to <code>ru_nswap</code> but is not supported by any
platform.</li>
<li><code>fsRead</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer&gt;</a> maps to <code>ru_inblock</code> which is the number of times the
file system had to perform input.</li>
<li><code>fsWrite</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer&gt;</a> maps to <code>ru_oublock</code> which is the number of times the
file system had to perform output.</li>
<li><code>ipcSent</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer&gt;</a> maps to <code>ru_msgsnd</code> but is not supported by any
platform.</li>
<li><code>ipcReceived</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer&gt;</a> maps to <code>ru_msgrcv</code> but is not supported by any
platform.</li>
<li><code>signalsCount</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer&gt;</a> maps to <code>ru_nsignals</code> but is not supported by any
platform.</li>
<li><code>voluntaryContextSwitches</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer&gt;</a> maps to <code>ru_nvcsw</code> which is the
number of times a CPU context switch resulted due to a process voluntarily
giving up the processor before its time slice was completed (usually to
await availability of a resource). This field is not supported on Windows.</li>
<li><code>involuntaryContextSwitches</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer&gt;</a> maps to <code>ru_nivcsw</code> which is the
number of times a CPU context switch resulted due to a higher priority
process becoming runnable or because the current process exceeded its
time slice. This field is not supported on Windows.</li>
</ul>
</li>
</ul>
<pre><code class="language-mjs">import { resourceUsage } from &#39;node:process&#39;;

console.log(resourceUsage());
/*
  Will output:
  {
    userCPUTime: 82872,
    systemCPUTime: 4143,
    maxRSS: 33164,
    sharedMemorySize: 0,
    unsharedDataSize: 0,
    unsharedStackSize: 0,
    minorPageFault: 2469,
    majorPageFault: 0,
    swappedOut: 0,
    fsRead: 0,
    fsWrite: 8,
    ipcSent: 0,
    ipcReceived: 0,
    signalsCount: 0,
    voluntaryContextSwitches: 79,
    involuntaryContextSwitches: 1
  }
*/
</code></pre>
<pre><code class="language-cjs">const { resourceUsage } = require(&#39;node:process&#39;);

console.log(resourceUsage());
/*
  Will output:
  {
    userCPUTime: 82872,
    systemCPUTime: 4143,
    maxRSS: 33164,
    sharedMemorySize: 0,
    unsharedDataSize: 0,
    unsharedStackSize: 0,
    minorPageFault: 2469,
    majorPageFault: 0,
    swappedOut: 0,
    fsRead: 0,
    fsWrite: 8,
    ipcSent: 0,
    ipcReceived: 0,
    signalsCount: 0,
    voluntaryContextSwitches: 79,
    involuntaryContextSwitches: 1
  }
*/
</code></pre>
</section><section><h3><code>process.send(message[, sendHandle[, options]][, callback])</code><span><a class="mark" href="#processsendmessage-sendhandle-options-callback" id="processsendmessage-sendhandle-options-callback">#</a></span><a aria-hidden="true" class="legacy" id="process_process_send_message_sendhandle_options_callback"></a></h3>
<div class="api_metadata">
<span>Added in: v0.5.9</span>
</div><ul>
<li><code>message</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type">&lt;Object&gt;</a></li>
<li><code>sendHandle</code> {net.Server|net.Socket}</li>
<li><code>options</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type">&lt;Object&gt;</a> used to parameterize the sending of certain types of
handles.<code>options</code> supports the following properties:<ul>
<li><code>keepOpen</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type" class="type">&lt;boolean&gt;</a> A value that can be used when passing instances of
<code>net.Socket</code>. When <code>true</code>, the socket is kept open in the sending process.
<strong>Default:</strong> <code>false</code>.</li>
</ul>
</li>
<li><code>callback</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function" class="type">&lt;Function&gt;</a></li>
<li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type" class="type">&lt;boolean&gt;</a></li>
</ul>
<p>If Node.js is spawned with an IPC channel, the <code>process.send()</code> method can be
used to send messages to the parent process. Messages will be received as a
<a href="child_process.html#event-message"><code>&#39;message&#39;</code></a> event on the parent&#39;s <a href="child_process.html#class-childprocess"><code>ChildProcess</code></a> object.</p>
<p>If Node.js was not spawned with an IPC channel, <code>process.send</code> will be
<code>undefined</code>.</p>
<p>The message goes through serialization and parsing. The resulting message might
not be the same as what is originally sent.</p>
</section><section><h3><code>process.setegid(id)</code><span><a class="mark" href="#processsetegidid" id="processsetegidid">#</a></span><a aria-hidden="true" class="legacy" id="process_process_setegid_id"></a></h3>
<div class="api_metadata">
<span>Added in: v2.0.0</span>
</div><ul>
<li><code>id</code> {string|number} A group name or ID</li>
</ul>
<p>The <code>process.setegid()</code> method sets the effective group identity of the process.
(See <a href="http://man7.org/linux/man-pages/man2/setegid.2.html"><code>setegid(2)</code></a>.) The <code>id</code> can be passed as either a numeric ID or a group
name string. If a group name is specified, this method blocks while resolving
the associated a numeric ID.</p>
<pre><code class="language-mjs">import process from &#39;node:process&#39;;

if (process.getegid &amp;&amp; process.setegid) {
  console.log(`Current gid: ${process.getegid()}`);
  try {
    process.setegid(501);
    console.log(`New gid: ${process.getegid()}`);
  } catch (err) {
    console.error(`Failed to set gid: ${err}`);
  }
}
</code></pre>
<pre><code class="language-cjs">const process = require(&#39;node:process&#39;);

if (process.getegid &amp;&amp; process.setegid) {
  console.log(`Current gid: ${process.getegid()}`);
  try {
    process.setegid(501);
    console.log(`New gid: ${process.getegid()}`);
  } catch (err) {
    console.error(`Failed to set gid: ${err}`);
  }
}
</code></pre>
<p>This function is only available on POSIX platforms (i.e. not Windows or
Android).
This feature is not available in <a href="worker_threads.html#class-worker"><code>Worker</code></a> threads.</p>
</section><section><h3><code>process.seteuid(id)</code><span><a class="mark" href="#processseteuidid" id="processseteuidid">#</a></span><a aria-hidden="true" class="legacy" id="process_process_seteuid_id"></a></h3>
<div class="api_metadata">
<span>Added in: v2.0.0</span>
</div><ul>
<li><code>id</code> {string|number} A user name or ID</li>
</ul>
<p>The <code>process.seteuid()</code> method sets the effective user identity of the process.
(See <a href="http://man7.org/linux/man-pages/man2/seteuid.2.html"><code>seteuid(2)</code></a>.) The <code>id</code> can be passed as either a numeric ID or a username
string. If a username is specified, the method blocks while resolving the
associated numeric ID.</p>
<pre><code class="language-mjs">import process from &#39;node:process&#39;;

if (process.geteuid &amp;&amp; process.seteuid) {
  console.log(`Current uid: ${process.geteuid()}`);
  try {
    process.seteuid(501);
    console.log(`New uid: ${process.geteuid()}`);
  } catch (err) {
    console.error(`Failed to set uid: ${err}`);
  }
}
</code></pre>
<pre><code class="language-cjs">const process = require(&#39;node:process&#39;);

if (process.geteuid &amp;&amp; process.seteuid) {
  console.log(`Current uid: ${process.geteuid()}`);
  try {
    process.seteuid(501);
    console.log(`New uid: ${process.geteuid()}`);
  } catch (err) {
    console.error(`Failed to set uid: ${err}`);
  }
}
</code></pre>
<p>This function is only available on POSIX platforms (i.e. not Windows or
Android).
This feature is not available in <a href="worker_threads.html#class-worker"><code>Worker</code></a> threads.</p>
</section><section><h3><code>process.setgid(id)</code><span><a class="mark" href="#processsetgidid" id="processsetgidid">#</a></span><a aria-hidden="true" class="legacy" id="process_process_setgid_id"></a></h3>
<div class="api_metadata">
<span>Added in: v0.1.31</span>
</div><ul>
<li><code>id</code> {string|number} The group name or ID</li>
</ul>
<p>The <code>process.setgid()</code> method sets the group identity of the process. (See
<a href="http://man7.org/linux/man-pages/man2/setgid.2.html"><code>setgid(2)</code></a>.) The <code>id</code> can be passed as either a numeric ID or a group name
string. If a group name is specified, this method blocks while resolving the
associated numeric ID.</p>
<pre><code class="language-mjs">import process from &#39;node:process&#39;;

if (process.getgid &amp;&amp; process.setgid) {
  console.log(`Current gid: ${process.getgid()}`);
  try {
    process.setgid(501);
    console.log(`New gid: ${process.getgid()}`);
  } catch (err) {
    console.error(`Failed to set gid: ${err}`);
  }
}
</code></pre>
<pre><code class="language-cjs">const process = require(&#39;node:process&#39;);

if (process.getgid &amp;&amp; process.setgid) {
  console.log(`Current gid: ${process.getgid()}`);
  try {
    process.setgid(501);
    console.log(`New gid: ${process.getgid()}`);
  } catch (err) {
    console.error(`Failed to set gid: ${err}`);
  }
}
</code></pre>
<p>This function is only available on POSIX platforms (i.e. not Windows or
Android).
This feature is not available in <a href="worker_threads.html#class-worker"><code>Worker</code></a> threads.</p>
</section><section><h3><code>process.setgroups(groups)</code><span><a class="mark" href="#processsetgroupsgroups" id="processsetgroupsgroups">#</a></span><a aria-hidden="true" class="legacy" id="process_process_setgroups_groups"></a></h3>
<div class="api_metadata">
<span>Added in: v0.9.4</span>
</div><ul>
<li><code>groups</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;integer[]&gt;</a></li>
</ul>
<p>The <code>process.setgroups()</code> method sets the supplementary group IDs for the
Node.js process. This is a privileged operation that requires the Node.js
process to have <code>root</code> or the <code>CAP_SETGID</code> capability.</p>
<p>The <code>groups</code> array can contain numeric group IDs, group names, or both.</p>
<pre><code class="language-mjs">import process from &#39;node:process&#39;;

if (process.getgroups &amp;&amp; process.setgroups) {
  try {
    process.setgroups([501]);
    console.log(process.getgroups()); // new groups
  } catch (err) {
    console.error(`Failed to set groups: ${err}`);
  }
}
</code></pre>
<pre><code class="language-cjs">const process = require(&#39;node:process&#39;);

if (process.getgroups &amp;&amp; process.setgroups) {
  try {
    process.setgroups([501]);
    console.log(process.getgroups()); // new groups
  } catch (err) {
    console.error(`Failed to set groups: ${err}`);
  }
}
</code></pre>
<p>This function is only available on POSIX platforms (i.e. not Windows or
Android).
This feature is not available in <a href="worker_threads.html#class-worker"><code>Worker</code></a> threads.</p>
</section><section><h3><code>process.setuid(id)</code><span><a class="mark" href="#processsetuidid" id="processsetuidid">#</a></span><a aria-hidden="true" class="legacy" id="process_process_setuid_id"></a></h3>
<div class="api_metadata">
<span>Added in: v0.1.28</span>
</div><ul>
<li><code>id</code> {integer | string}</li>
</ul>
<p>The <code>process.setuid(id)</code> method sets the user identity of the process. (See
<a href="http://man7.org/linux/man-pages/man2/setuid.2.html"><code>setuid(2)</code></a>.) The <code>id</code> can be passed as either a numeric ID or a username string.
If a username is specified, the method blocks while resolving the associated
numeric ID.</p>
<pre><code class="language-mjs">import process from &#39;node:process&#39;;

if (process.getuid &amp;&amp; process.setuid) {
  console.log(`Current uid: ${process.getuid()}`);
  try {
    process.setuid(501);
    console.log(`New uid: ${process.getuid()}`);
  } catch (err) {
    console.error(`Failed to set uid: ${err}`);
  }
}
</code></pre>
<pre><code class="language-cjs">const process = require(&#39;node:process&#39;);

if (process.getuid &amp;&amp; process.setuid) {
  console.log(`Current uid: ${process.getuid()}`);
  try {
    process.setuid(501);
    console.log(`New uid: ${process.getuid()}`);
  } catch (err) {
    console.error(`Failed to set uid: ${err}`);
  }
}
</code></pre>
<p>This function is only available on POSIX platforms (i.e. not Windows or
Android).
This feature is not available in <a href="worker_threads.html#class-worker"><code>Worker</code></a> threads.</p>
</section><section><h3><code>process.setSourceMapsEnabled(val)</code><span><a class="mark" href="#processsetsourcemapsenabledval" id="processsetsourcemapsenabledval">#</a></span><a aria-hidden="true" class="legacy" id="process_process_setsourcemapsenabled_val"></a></h3>
<div class="api_metadata">
<span>Added in: v16.6.0, v14.18.0</span>
</div><blockquote>
<p>Stability: 1 - Experimental</p>
</blockquote>
<ul>
<li><code>val</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type" class="type">&lt;boolean&gt;</a></li>
</ul>
<p>This function enables or disables the <a href="https://sourcemaps.info/spec.html">Source Map v3</a> support for
stack traces.</p>
<p>It provides same features as launching Node.js process with commandline options
<code>--enable-source-maps</code>.</p>
<p>Only source maps in JavaScript files that are loaded after source maps has been
enabled will be parsed and loaded.</p>
</section><section><h3><code>process.setUncaughtExceptionCaptureCallback(fn)</code><span><a class="mark" href="#processsetuncaughtexceptioncapturecallbackfn" id="processsetuncaughtexceptioncapturecallbackfn">#</a></span><a aria-hidden="true" class="legacy" id="process_process_setuncaughtexceptioncapturecallback_fn"></a></h3>
<div class="api_metadata">
<span>Added in: v9.3.0</span>
</div><ul>
<li><code>fn</code> {Function|null}</li>
</ul>
<p>The <code>process.setUncaughtExceptionCaptureCallback()</code> function sets a function
that will be invoked when an uncaught exception occurs, which will receive the
exception value itself as its first argument.</p>
<p>If such a function is set, the <a href="#event-uncaughtexception"><code>&#39;uncaughtException&#39;</code></a> event will
not be emitted. If <code>--abort-on-uncaught-exception</code> was passed from the
command line or set through <a href="v8.html#v8setflagsfromstringflags"><code>v8.setFlagsFromString()</code></a>, the process will
not abort. Actions configured to take place on exceptions such as report
generations will be affected too</p>
<p>To unset the capture function,
<code>process.setUncaughtExceptionCaptureCallback(null)</code> may be used. Calling this
method with a non-<code>null</code> argument while another capture function is set will
throw an error.</p>
<p>Using this function is mutually exclusive with using the deprecated
<a href="domain.html"><code>domain</code></a> built-in module.</p>
</section><section><h3><code>process.sourceMapsEnabled</code><span><a class="mark" href="#processsourcemapsenabled" id="processsourcemapsenabled">#</a></span><a aria-hidden="true" class="legacy" id="process_process_sourcemapsenabled"></a></h3>
<div class="api_metadata">
<span>Added in: v18.19.0</span>
</div><blockquote>
<p>Stability: 1 - Experimental</p>
</blockquote>
<ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type" class="type">&lt;boolean&gt;</a></li>
</ul>
<p>The <code>process.sourceMapsEnabled</code> property returns whether the
<a href="https://sourcemaps.info/spec.html">Source Map v3</a> support for stack traces is enabled.</p>
</section><section><h3><code>process.stderr</code><span><a class="mark" href="#processstderr" id="processstderr">#</a></span><a aria-hidden="true" class="legacy" id="process_process_stderr"></a></h3>
<ul>
<li><a href="stream.html#stream" class="type">&lt;Stream&gt;</a></li>
</ul>
<p>The <code>process.stderr</code> property returns a stream connected to
<code>stderr</code> (fd <code>2</code>). It is a <a href="net.html#class-netsocket"><code>net.Socket</code></a> (which is a <a href="stream.html#duplex-and-transform-streams">Duplex</a>
stream) unless fd <code>2</code> refers to a file, in which case it is
a <a href="stream.html#writable-streams">Writable</a> stream.</p>
<p><code>process.stderr</code> differs from other Node.js streams in important ways. See
<a href="#a-note-on-process-io">note on process I/O</a> for more information.</p>
<h4><code>process.stderr.fd</code><span><a class="mark" href="#processstderrfd" id="processstderrfd">#</a></span><a aria-hidden="true" class="legacy" id="process_process_stderr_fd"></a></h4>
<ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;number&gt;</a></li>
</ul>
<p>This property refers to the value of underlying file descriptor of
<code>process.stderr</code>. The value is fixed at <code>2</code>. In <a href="worker_threads.html#class-worker"><code>Worker</code></a> threads,
this field does not exist.</p>
</section><section><h3><code>process.stdin</code><span><a class="mark" href="#processstdin" id="processstdin">#</a></span><a aria-hidden="true" class="legacy" id="process_process_stdin"></a></h3>
<ul>
<li><a href="stream.html#stream" class="type">&lt;Stream&gt;</a></li>
</ul>
<p>The <code>process.stdin</code> property returns a stream connected to
<code>stdin</code> (fd <code>0</code>). It is a <a href="net.html#class-netsocket"><code>net.Socket</code></a> (which is a <a href="stream.html#duplex-and-transform-streams">Duplex</a>
stream) unless fd <code>0</code> refers to a file, in which case it is
a <a href="stream.html#readable-streams">Readable</a> stream.</p>
<p>For details of how to read from <code>stdin</code> see <a href="stream.html#readablereadsize"><code>readable.read()</code></a>.</p>
<p>As a <a href="stream.html#duplex-and-transform-streams">Duplex</a> stream, <code>process.stdin</code> can also be used in &quot;old&quot; mode that
is compatible with scripts written for Node.js prior to v0.10.
For more information see <a href="stream.html#compatibility-with-older-nodejs-versions">Stream compatibility</a>.</p>
<p>In &quot;old&quot; streams mode the <code>stdin</code> stream is paused by default, so one
must call <code>process.stdin.resume()</code> to read from it. Note also that calling
<code>process.stdin.resume()</code> itself would switch stream to &quot;old&quot; mode.</p>
<h4><code>process.stdin.fd</code><span><a class="mark" href="#processstdinfd" id="processstdinfd">#</a></span><a aria-hidden="true" class="legacy" id="process_process_stdin_fd"></a></h4>
<ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;number&gt;</a></li>
</ul>
<p>This property refers to the value of underlying file descriptor of
<code>process.stdin</code>. The value is fixed at <code>0</code>. In <a href="worker_threads.html#class-worker"><code>Worker</code></a> threads,
this field does not exist.</p>
</section><section><h3><code>process.stdout</code><span><a class="mark" href="#processstdout" id="processstdout">#</a></span><a aria-hidden="true" class="legacy" id="process_process_stdout"></a></h3>
<ul>
<li><a href="stream.html#stream" class="type">&lt;Stream&gt;</a></li>
</ul>
<p>The <code>process.stdout</code> property returns a stream connected to
<code>stdout</code> (fd <code>1</code>). It is a <a href="net.html#class-netsocket"><code>net.Socket</code></a> (which is a <a href="stream.html#duplex-and-transform-streams">Duplex</a>
stream) unless fd <code>1</code> refers to a file, in which case it is
a <a href="stream.html#writable-streams">Writable</a> stream.</p>
<p>For example, to copy <code>process.stdin</code> to <code>process.stdout</code>:</p>
<pre><code class="language-mjs">import { stdin, stdout } from &#39;node:process&#39;;

stdin.pipe(stdout);
</code></pre>
<pre><code class="language-cjs">const { stdin, stdout } = require(&#39;node:process&#39;);

stdin.pipe(stdout);
</code></pre>
<p><code>process.stdout</code> differs from other Node.js streams in important ways. See
<a href="#a-note-on-process-io">note on process I/O</a> for more information.</p>
<h4><code>process.stdout.fd</code><span><a class="mark" href="#processstdoutfd" id="processstdoutfd">#</a></span><a aria-hidden="true" class="legacy" id="process_process_stdout_fd"></a></h4>
<ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;number&gt;</a></li>
</ul>
<p>This property refers to the value of underlying file descriptor of
<code>process.stdout</code>. The value is fixed at <code>1</code>. In <a href="worker_threads.html#class-worker"><code>Worker</code></a> threads,
this field does not exist.</p>
<h4>A note on process I/O<span><a class="mark" href="#a-note-on-process-io" id="a-note-on-process-io">#</a></span><a aria-hidden="true" class="legacy" id="process_a_note_on_process_i_o"></a></h4>
<p><code>process.stdout</code> and <code>process.stderr</code> differ from other Node.js streams in
important ways:</p>
<ol>
<li>They are used internally by <a href="console.html#consolelogdata-args"><code>console.log()</code></a> and <a href="console.html#consoleerrordata-args"><code>console.error()</code></a>,
respectively.</li>
<li>Writes may be synchronous depending on what the stream is connected to
and whether the system is Windows or POSIX:<ul>
<li>Files: <em>synchronous</em> on Windows and POSIX</li>
<li>TTYs (Terminals): <em>asynchronous</em> on Windows, <em>synchronous</em> on POSIX</li>
<li>Pipes (and sockets): <em>synchronous</em> on Windows, <em>asynchronous</em> on POSIX</li>
</ul>
</li>
</ol>
<p>These behaviors are partly for historical reasons, as changing them would
create backward incompatibility, but they are also expected by some users.</p>
<p>Synchronous writes avoid problems such as output written with <code>console.log()</code> or
<code>console.error()</code> being unexpectedly interleaved, or not written at all if
<code>process.exit()</code> is called before an asynchronous write completes. See
<a href="#processexitcode"><code>process.exit()</code></a> for more information.</p>
<p><em><strong>Warning</strong></em>: Synchronous writes block the event loop until the write has
completed. This can be near instantaneous in the case of output to a file, but
under high system load, pipes that are not being read at the receiving end, or
with slow terminals or file systems, it&#39;s possible for the event loop to be
blocked often enough and long enough to have severe negative performance
impacts. This may not be a problem when writing to an interactive terminal
session, but consider this particularly careful when doing production logging to
the process output streams.</p>
<p>To check if a stream is connected to a <a href="tty.html#tty">TTY</a> context, check the <code>isTTY</code>
property.</p>
<p>For instance:</p>
<pre><code class="language-console">$ node -p &quot;Boolean(process.stdin.isTTY)&quot;
true
$ echo &quot;foo&quot; | node -p &quot;Boolean(process.stdin.isTTY)&quot;
false
$ node -p &quot;Boolean(process.stdout.isTTY)&quot;
true
$ node -p &quot;Boolean(process.stdout.isTTY)&quot; | cat
false
</code></pre>
<p>See the <a href="tty.html#tty">TTY</a> documentation for more information.</p>
</section><section><h3><code>process.throwDeprecation</code><span><a class="mark" href="#processthrowdeprecation" id="processthrowdeprecation">#</a></span><a aria-hidden="true" class="legacy" id="process_process_throwdeprecation"></a></h3>
<div class="api_metadata">
<span>Added in: v0.9.12</span>
</div><ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type" class="type">&lt;boolean&gt;</a></li>
</ul>
<p>The initial value of <code>process.throwDeprecation</code> indicates whether the
<code>--throw-deprecation</code> flag is set on the current Node.js process.
<code>process.throwDeprecation</code> is mutable, so whether or not deprecation
warnings result in errors may be altered at runtime. See the
documentation for the <a href="#event-warning"><code>&#39;warning&#39;</code> event</a> and the
<a href="#processemitwarningwarning-type-code-ctor"><code>emitWarning()</code> method</a> for more information.</p>
<pre><code class="language-console">$ node --throw-deprecation -p &quot;process.throwDeprecation&quot;
true
$ node -p &quot;process.throwDeprecation&quot;
undefined
$ node
&gt; process.emitWarning(&#39;test&#39;, &#39;DeprecationWarning&#39;);
undefined
&gt; (node:26598) DeprecationWarning: test
&gt; process.throwDeprecation = true;
true
&gt; process.emitWarning(&#39;test&#39;, &#39;DeprecationWarning&#39;);
Thrown:
[DeprecationWarning: test] { name: &#39;DeprecationWarning&#39; }
</code></pre>
</section><section><h3><code>process.title</code><span><a class="mark" href="#processtitle" id="processtitle">#</a></span><a aria-hidden="true" class="legacy" id="process_process_title"></a></h3>
<div class="api_metadata">
<span>Added in: v0.1.104</span>
</div><ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a></li>
</ul>
<p>The <code>process.title</code> property returns the current process title (i.e. returns
the current value of <code>ps</code>). Assigning a new value to <code>process.title</code> modifies
the current value of <code>ps</code>.</p>
<p>When a new value is assigned, different platforms will impose different maximum
length restrictions on the title. Usually such restrictions are quite limited.
For instance, on Linux and macOS, <code>process.title</code> is limited to the size of the
binary name plus the length of the command-line arguments because setting the
<code>process.title</code> overwrites the <code>argv</code> memory of the process. Node.js v0.8
allowed for longer process title strings by also overwriting the <code>environ</code>
memory but that was potentially insecure and confusing in some (rather obscure)
cases.</p>
<p>Assigning a value to <code>process.title</code> might not result in an accurate label
within process manager applications such as macOS Activity Monitor or Windows
Services Manager.</p>
</section><section><h3><code>process.traceDeprecation</code><span><a class="mark" href="#processtracedeprecation" id="processtracedeprecation">#</a></span><a aria-hidden="true" class="legacy" id="process_process_tracedeprecation"></a></h3>
<div class="api_metadata">
<span>Added in: v0.8.0</span>
</div><ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type" class="type">&lt;boolean&gt;</a></li>
</ul>
<p>The <code>process.traceDeprecation</code> property indicates whether the
<code>--trace-deprecation</code> flag is set on the current Node.js process. See the
documentation for the <a href="#event-warning"><code>&#39;warning&#39;</code> event</a> and the
<a href="#processemitwarningwarning-type-code-ctor"><code>emitWarning()</code> method</a> for more information about this
flag&#39;s behavior.</p>
</section><section><h3><code>process.umask()</code><span><a class="mark" href="#processumask" id="processumask">#</a></span><a aria-hidden="true" class="legacy" id="process_process_umask"></a></h3>
<div class="api_metadata">
<details class="changelog"><summary>History</summary>
<table>
<tr><th>Version</th><th>Changes</th></tr>
<tr><td>v14.0.0, v12.19.0</td>
<td><p>Calling <code>process.umask()</code> with no arguments is deprecated.</p>
</td></tr>
<tr><td>v0.1.19</td>
<td><p><span>Added in: v0.1.19</span></p>
</td></tr>
</table>
</details>
</div><blockquote>
<p>Stability: 0 - Deprecated. Calling <code>process.umask()</code> with no argument causes
the process-wide umask to be written twice. This introduces a race condition
between threads, and is a potential security vulnerability. There is no safe,
cross-platform alternative API.</p>
</blockquote>
<p><code>process.umask()</code> returns the Node.js process&#39;s file mode creation mask. Child
processes inherit the mask from the parent process.</p>
</section><section><h3><code>process.umask(mask)</code><span><a class="mark" href="#processumaskmask" id="processumaskmask">#</a></span><a aria-hidden="true" class="legacy" id="process_process_umask_mask"></a></h3>
<div class="api_metadata">
<span>Added in: v0.1.19</span>
</div><ul>
<li><code>mask</code> {string|integer}</li>
</ul>
<p><code>process.umask(mask)</code> sets the Node.js process&#39;s file mode creation mask. Child
processes inherit the mask from the parent process. Returns the previous mask.</p>
<pre><code class="language-mjs">import { umask } from &#39;node:process&#39;;

const newmask = 0o022;
const oldmask = umask(newmask);
console.log(
  `Changed umask from ${oldmask.toString(8)} to ${newmask.toString(8)}`,
);
</code></pre>
<pre><code class="language-cjs">const { umask } = require(&#39;node:process&#39;);

const newmask = 0o022;
const oldmask = umask(newmask);
console.log(
  `Changed umask from ${oldmask.toString(8)} to ${newmask.toString(8)}`,
);
</code></pre>
<p>In <a href="worker_threads.html#class-worker"><code>Worker</code></a> threads, <code>process.umask(mask)</code> will throw an exception.</p>
</section><section><h3><code>process.uptime()</code><span><a class="mark" href="#processuptime" id="processuptime">#</a></span><a aria-hidden="true" class="legacy" id="process_process_uptime"></a></h3>
<div class="api_metadata">
<span>Added in: v0.5.0</span>
</div><ul>
<li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;number&gt;</a></li>
</ul>
<p>The <code>process.uptime()</code> method returns the number of seconds the current Node.js
process has been running.</p>
<p>The return value includes fractions of a second. Use <code>Math.floor()</code> to get whole
seconds.</p>
</section><section><h3><code>process.version</code><span><a class="mark" href="#processversion" id="processversion">#</a></span><a aria-hidden="true" class="legacy" id="process_process_version"></a></h3>
<div class="api_metadata">
<span>Added in: v0.1.3</span>
</div><ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a></li>
</ul>
<p>The <code>process.version</code> property contains the Node.js version string.</p>
<pre><code class="language-mjs">import { version } from &#39;node:process&#39;;

console.log(`Version: ${version}`);
// Version: v14.8.0
</code></pre>
<pre><code class="language-cjs">const { version } = require(&#39;node:process&#39;);

console.log(`Version: ${version}`);
// Version: v14.8.0
</code></pre>
<p>To get the version string without the prepended <em>v</em>, use
<code>process.versions.node</code>.</p>
</section><section><h3><code>process.versions</code><span><a class="mark" href="#processversions" id="processversions">#</a></span><a aria-hidden="true" class="legacy" id="process_process_versions"></a></h3>
<div class="api_metadata">
<details class="changelog"><summary>History</summary>
<table>
<tr><th>Version</th><th>Changes</th></tr>
<tr><td>v9.0.0</td>
<td><p>The <code>v8</code> property now includes a Node.js specific suffix.</p>
</td></tr>
<tr><td>v4.2.0</td>
<td><p>The <code>icu</code> property is now supported.</p>
</td></tr>
<tr><td>v0.2.0</td>
<td><p><span>Added in: v0.2.0</span></p>
</td></tr>
</table>
</details>
</div><ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type">&lt;Object&gt;</a></li>
</ul>
<p>The <code>process.versions</code> property returns an object listing the version strings of
Node.js and its dependencies. <code>process.versions.modules</code> indicates the current
ABI version, which is increased whenever a C++ API changes. Node.js will refuse
to load modules that were compiled against a different module ABI version.</p>
<pre><code class="language-mjs">import { versions } from &#39;node:process&#39;;

console.log(versions);
</code></pre>
<pre><code class="language-cjs">const { versions } = require(&#39;node:process&#39;);

console.log(versions);
</code></pre>
<p>Will generate an object similar to:</p>
<pre><code class="language-console">{ node: &#39;11.13.0&#39;,
  v8: &#39;7.0.276.38-node.18&#39;,
  uv: &#39;1.27.0&#39;,
  zlib: &#39;1.2.11&#39;,
  brotli: &#39;1.0.7&#39;,
  ares: &#39;1.15.0&#39;,
  modules: &#39;67&#39;,
  nghttp2: &#39;1.34.0&#39;,
  napi: &#39;4&#39;,
  llhttp: &#39;1.1.1&#39;,
  openssl: &#39;1.1.1b&#39;,
  cldr: &#39;34.0&#39;,
  icu: &#39;63.1&#39;,
  tz: &#39;2018e&#39;,
  unicode: &#39;11.0&#39; }
</code></pre>
</section><section><h3>Exit codes<span><a class="mark" href="#exit-codes" id="exit-codes">#</a></span><a aria-hidden="true" class="legacy" id="process_exit_codes"></a></h3>
<p>Node.js will normally exit with a <code>0</code> status code when no more async
operations are pending. The following status codes are used in other
cases:</p>
<ul>
<li><code>1</code> <strong>Uncaught Fatal Exception</strong>: There was an uncaught exception,
and it was not handled by a domain or an <a href="#event-uncaughtexception"><code>&#39;uncaughtException&#39;</code></a> event
handler.</li>
<li><code>2</code>: Unused (reserved by Bash for builtin misuse)</li>
<li><code>3</code> <strong>Internal JavaScript Parse Error</strong>: The JavaScript source code
internal in the Node.js bootstrapping process caused a parse error. This
is extremely rare, and generally can only happen during development
of Node.js itself.</li>
<li><code>4</code> <strong>Internal JavaScript Evaluation Failure</strong>: The JavaScript
source code internal in the Node.js bootstrapping process failed to
return a function value when evaluated. This is extremely rare, and
generally can only happen during development of Node.js itself.</li>
<li><code>5</code> <strong>Fatal Error</strong>: There was a fatal unrecoverable error in V8.
Typically a message will be printed to stderr with the prefix <code>FATAL ERROR</code>.</li>
<li><code>6</code> <strong>Non-function Internal Exception Handler</strong>: There was an
uncaught exception, but the internal fatal exception handler
function was somehow set to a non-function, and could not be called.</li>
<li><code>7</code> <strong>Internal Exception Handler Run-Time Failure</strong>: There was an
uncaught exception, and the internal fatal exception handler
function itself threw an error while attempting to handle it. This
can happen, for example, if an <a href="#event-uncaughtexception"><code>&#39;uncaughtException&#39;</code></a> or
<code>domain.on(&#39;error&#39;)</code> handler throws an error.</li>
<li><code>8</code>: Unused. In previous versions of Node.js, exit code 8 sometimes
indicated an uncaught exception.</li>
<li><code>9</code> <strong>Invalid Argument</strong>: Either an unknown option was specified,
or an option requiring a value was provided without a value.</li>
<li><code>10</code> <strong>Internal JavaScript Run-Time Failure</strong>: The JavaScript
source code internal in the Node.js bootstrapping process threw an error
when the bootstrapping function was called. This is extremely rare,
and generally can only happen during development of Node.js itself.</li>
<li><code>12</code> <strong>Invalid Debug Argument</strong>: The <code>--inspect</code> and/or <code>--inspect-brk</code>
options were set, but the port number chosen was invalid or unavailable.</li>
<li><code>13</code> <strong>Unfinished Top-Level Await</strong>: <code>await</code> was used outside of a function
in the top-level code, but the passed <code>Promise</code> never resolved.</li>
<li><code>14</code> <strong>Snapshot Failure</strong>: Node.js was started to build a V8 startup
snapshot and it failed because certain requirements of the state of
the application were not met.</li>
<li><code>&gt;128</code> <strong>Signal Exits</strong>: If Node.js receives a fatal signal such as
<code>SIGKILL</code> or <code>SIGHUP</code>, then its exit code will be <code>128</code> plus the
value of the signal code. This is a standard POSIX practice, since
exit codes are defined to be 7-bit integers, and signal exits set
the high-order bit, and then contain the value of the signal code.
For example, signal <code>SIGABRT</code> has value <code>6</code>, so the expected exit
code will be <code>128</code> + <code>6</code>, or <code>134</code>.</li>
</ul>
</section>
        <!-- API END -->
      </div>
    </div>
  </div>
</body>
</html>

Zerion Mini Shell 1.0