10889fd2c4d9511987dbef073e8827737af6b04da54f57aa4e0f3a760c2b8f9441b258ad739becbb5f8e124b60bf28b34b78fe456f8b1b0456dd35670d1ba4 103 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063
  1. declare module "process" {
  2. import * as tty from "node:tty";
  3. import { Worker } from "node:worker_threads";
  4. interface BuiltInModule {
  5. "assert": typeof import("assert");
  6. "node:assert": typeof import("node:assert");
  7. "assert/strict": typeof import("assert/strict");
  8. "node:assert/strict": typeof import("node:assert/strict");
  9. "async_hooks": typeof import("async_hooks");
  10. "node:async_hooks": typeof import("node:async_hooks");
  11. "buffer": typeof import("buffer");
  12. "node:buffer": typeof import("node:buffer");
  13. "child_process": typeof import("child_process");
  14. "node:child_process": typeof import("node:child_process");
  15. "cluster": typeof import("cluster");
  16. "node:cluster": typeof import("node:cluster");
  17. "console": typeof import("console");
  18. "node:console": typeof import("node:console");
  19. "constants": typeof import("constants");
  20. "node:constants": typeof import("node:constants");
  21. "crypto": typeof import("crypto");
  22. "node:crypto": typeof import("node:crypto");
  23. "dgram": typeof import("dgram");
  24. "node:dgram": typeof import("node:dgram");
  25. "diagnostics_channel": typeof import("diagnostics_channel");
  26. "node:diagnostics_channel": typeof import("node:diagnostics_channel");
  27. "dns": typeof import("dns");
  28. "node:dns": typeof import("node:dns");
  29. "dns/promises": typeof import("dns/promises");
  30. "node:dns/promises": typeof import("node:dns/promises");
  31. "domain": typeof import("domain");
  32. "node:domain": typeof import("node:domain");
  33. "events": typeof import("events");
  34. "node:events": typeof import("node:events");
  35. "fs": typeof import("fs");
  36. "node:fs": typeof import("node:fs");
  37. "fs/promises": typeof import("fs/promises");
  38. "node:fs/promises": typeof import("node:fs/promises");
  39. "http": typeof import("http");
  40. "node:http": typeof import("node:http");
  41. "http2": typeof import("http2");
  42. "node:http2": typeof import("node:http2");
  43. "https": typeof import("https");
  44. "node:https": typeof import("node:https");
  45. "inspector": typeof import("inspector");
  46. "node:inspector": typeof import("node:inspector");
  47. "inspector/promises": typeof import("inspector/promises");
  48. "node:inspector/promises": typeof import("node:inspector/promises");
  49. "module": typeof import("module");
  50. "node:module": typeof import("node:module");
  51. "net": typeof import("net");
  52. "node:net": typeof import("node:net");
  53. "os": typeof import("os");
  54. "node:os": typeof import("node:os");
  55. "path": typeof import("path");
  56. "node:path": typeof import("node:path");
  57. "path/posix": typeof import("path/posix");
  58. "node:path/posix": typeof import("node:path/posix");
  59. "path/win32": typeof import("path/win32");
  60. "node:path/win32": typeof import("node:path/win32");
  61. "perf_hooks": typeof import("perf_hooks");
  62. "node:perf_hooks": typeof import("node:perf_hooks");
  63. "process": typeof import("process");
  64. "node:process": typeof import("node:process");
  65. "punycode": typeof import("punycode");
  66. "node:punycode": typeof import("node:punycode");
  67. "querystring": typeof import("querystring");
  68. "node:querystring": typeof import("node:querystring");
  69. "readline": typeof import("readline");
  70. "node:readline": typeof import("node:readline");
  71. "readline/promises": typeof import("readline/promises");
  72. "node:readline/promises": typeof import("node:readline/promises");
  73. "repl": typeof import("repl");
  74. "node:repl": typeof import("node:repl");
  75. "node:sea": typeof import("node:sea");
  76. "node:sqlite": typeof import("node:sqlite");
  77. "stream": typeof import("stream");
  78. "node:stream": typeof import("node:stream");
  79. "stream/consumers": typeof import("stream/consumers");
  80. "node:stream/consumers": typeof import("node:stream/consumers");
  81. "stream/promises": typeof import("stream/promises");
  82. "node:stream/promises": typeof import("node:stream/promises");
  83. "stream/web": typeof import("stream/web");
  84. "node:stream/web": typeof import("node:stream/web");
  85. "string_decoder": typeof import("string_decoder");
  86. "node:string_decoder": typeof import("node:string_decoder");
  87. "node:test": typeof import("node:test");
  88. "node:test/reporters": typeof import("node:test/reporters");
  89. "timers": typeof import("timers");
  90. "node:timers": typeof import("node:timers");
  91. "timers/promises": typeof import("timers/promises");
  92. "node:timers/promises": typeof import("node:timers/promises");
  93. "tls": typeof import("tls");
  94. "node:tls": typeof import("node:tls");
  95. "trace_events": typeof import("trace_events");
  96. "node:trace_events": typeof import("node:trace_events");
  97. "tty": typeof import("tty");
  98. "node:tty": typeof import("node:tty");
  99. "url": typeof import("url");
  100. "node:url": typeof import("node:url");
  101. "util": typeof import("util");
  102. "node:util": typeof import("node:util");
  103. "sys": typeof import("util");
  104. "node:sys": typeof import("node:util");
  105. "util/types": typeof import("util/types");
  106. "node:util/types": typeof import("node:util/types");
  107. "v8": typeof import("v8");
  108. "node:v8": typeof import("node:v8");
  109. "vm": typeof import("vm");
  110. "node:vm": typeof import("node:vm");
  111. "wasi": typeof import("wasi");
  112. "node:wasi": typeof import("node:wasi");
  113. "worker_threads": typeof import("worker_threads");
  114. "node:worker_threads": typeof import("node:worker_threads");
  115. "zlib": typeof import("zlib");
  116. "node:zlib": typeof import("node:zlib");
  117. }
  118. global {
  119. var process: NodeJS.Process;
  120. namespace NodeJS {
  121. // this namespace merge is here because these are specifically used
  122. // as the type for process.stdin, process.stdout, and process.stderr.
  123. // they can't live in tty.d.ts because we need to disambiguate the imported name.
  124. interface ReadStream extends tty.ReadStream {}
  125. interface WriteStream extends tty.WriteStream {}
  126. interface MemoryUsageFn {
  127. /**
  128. * The `process.memoryUsage()` method iterate over each page to gather informations about memory
  129. * usage which can be slow depending on the program memory allocations.
  130. */
  131. (): MemoryUsage;
  132. /**
  133. * method returns an integer representing the Resident Set Size (RSS) in bytes.
  134. */
  135. rss(): number;
  136. }
  137. interface MemoryUsage {
  138. /**
  139. * 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
  140. * process, including all C++ and JavaScript objects and code.
  141. */
  142. rss: number;
  143. /**
  144. * Refers to V8's memory usage.
  145. */
  146. heapTotal: number;
  147. /**
  148. * Refers to V8's memory usage.
  149. */
  150. heapUsed: number;
  151. external: number;
  152. /**
  153. * Refers to memory allocated for `ArrayBuffer`s and `SharedArrayBuffer`s, including all Node.js Buffers. This is also included
  154. * in the external value. When Node.js is used as an embedded library, this value may be `0` because allocations for `ArrayBuffer`s
  155. * may not be tracked in that case.
  156. */
  157. arrayBuffers: number;
  158. }
  159. interface CpuUsage {
  160. user: number;
  161. system: number;
  162. }
  163. interface ProcessRelease {
  164. name: string;
  165. sourceUrl?: string | undefined;
  166. headersUrl?: string | undefined;
  167. libUrl?: string | undefined;
  168. lts?: string | undefined;
  169. }
  170. interface ProcessFeatures {
  171. /**
  172. * A boolean value that is `true` if the current Node.js build is caching builtin modules.
  173. * @since v12.0.0
  174. */
  175. readonly cached_builtins: boolean;
  176. /**
  177. * A boolean value that is `true` if the current Node.js build is a debug build.
  178. * @since v0.5.5
  179. */
  180. readonly debug: boolean;
  181. /**
  182. * A boolean value that is `true` if the current Node.js build includes the inspector.
  183. * @since v11.10.0
  184. */
  185. readonly inspector: boolean;
  186. /**
  187. * A boolean value that is `true` if the current Node.js build includes support for IPv6.
  188. *
  189. * Since all Node.js builds have IPv6 support, this value is always `true`.
  190. * @since v0.5.3
  191. * @deprecated This property is always true, and any checks based on it are redundant.
  192. */
  193. readonly ipv6: boolean;
  194. /**
  195. * A boolean value that is `true` if the current Node.js build supports
  196. * [loading ECMAScript modules using `require()`](https://nodejs.org/docs/latest-v22.x/api/modules.md#loading-ecmascript-modules-using-require).
  197. * @since v22.10.0
  198. */
  199. readonly require_module: boolean;
  200. /**
  201. * A boolean value that is `true` if the current Node.js build includes support for TLS.
  202. * @since v0.5.3
  203. */
  204. readonly tls: boolean;
  205. /**
  206. * A boolean value that is `true` if the current Node.js build includes support for ALPN in TLS.
  207. *
  208. * In Node.js 11.0.0 and later versions, the OpenSSL dependencies feature unconditional ALPN support.
  209. * This value is therefore identical to that of `process.features.tls`.
  210. * @since v4.8.0
  211. * @deprecated Use `process.features.tls` instead.
  212. */
  213. readonly tls_alpn: boolean;
  214. /**
  215. * A boolean value that is `true` if the current Node.js build includes support for OCSP in TLS.
  216. *
  217. * In Node.js 11.0.0 and later versions, the OpenSSL dependencies feature unconditional OCSP support.
  218. * This value is therefore identical to that of `process.features.tls`.
  219. * @since v0.11.13
  220. * @deprecated Use `process.features.tls` instead.
  221. */
  222. readonly tls_ocsp: boolean;
  223. /**
  224. * A boolean value that is `true` if the current Node.js build includes support for SNI in TLS.
  225. *
  226. * In Node.js 11.0.0 and later versions, the OpenSSL dependencies feature unconditional SNI support.
  227. * This value is therefore identical to that of `process.features.tls`.
  228. * @since v0.5.3
  229. * @deprecated Use `process.features.tls` instead.
  230. */
  231. readonly tls_sni: boolean;
  232. /**
  233. * A value that is `"strip"` if Node.js is run with `--experimental-strip-types`,
  234. * `"transform"` if Node.js is run with `--experimental-transform-types`, and `false` otherwise.
  235. * @since v22.10.0
  236. */
  237. readonly typescript: "strip" | "transform" | false;
  238. /**
  239. * A boolean value that is `true` if the current Node.js build includes support for libuv.
  240. *
  241. * Since it's not possible to build Node.js without libuv, this value is always `true`.
  242. * @since v0.5.3
  243. * @deprecated This property is always true, and any checks based on it are redundant.
  244. */
  245. readonly uv: boolean;
  246. }
  247. interface ProcessVersions extends Dict<string> {
  248. http_parser: string;
  249. node: string;
  250. v8: string;
  251. ares: string;
  252. uv: string;
  253. zlib: string;
  254. modules: string;
  255. openssl: string;
  256. }
  257. type Platform =
  258. | "aix"
  259. | "android"
  260. | "darwin"
  261. | "freebsd"
  262. | "haiku"
  263. | "linux"
  264. | "openbsd"
  265. | "sunos"
  266. | "win32"
  267. | "cygwin"
  268. | "netbsd";
  269. type Architecture =
  270. | "arm"
  271. | "arm64"
  272. | "ia32"
  273. | "loong64"
  274. | "mips"
  275. | "mipsel"
  276. | "ppc"
  277. | "ppc64"
  278. | "riscv64"
  279. | "s390"
  280. | "s390x"
  281. | "x64";
  282. type Signals =
  283. | "SIGABRT"
  284. | "SIGALRM"
  285. | "SIGBUS"
  286. | "SIGCHLD"
  287. | "SIGCONT"
  288. | "SIGFPE"
  289. | "SIGHUP"
  290. | "SIGILL"
  291. | "SIGINT"
  292. | "SIGIO"
  293. | "SIGIOT"
  294. | "SIGKILL"
  295. | "SIGPIPE"
  296. | "SIGPOLL"
  297. | "SIGPROF"
  298. | "SIGPWR"
  299. | "SIGQUIT"
  300. | "SIGSEGV"
  301. | "SIGSTKFLT"
  302. | "SIGSTOP"
  303. | "SIGSYS"
  304. | "SIGTERM"
  305. | "SIGTRAP"
  306. | "SIGTSTP"
  307. | "SIGTTIN"
  308. | "SIGTTOU"
  309. | "SIGUNUSED"
  310. | "SIGURG"
  311. | "SIGUSR1"
  312. | "SIGUSR2"
  313. | "SIGVTALRM"
  314. | "SIGWINCH"
  315. | "SIGXCPU"
  316. | "SIGXFSZ"
  317. | "SIGBREAK"
  318. | "SIGLOST"
  319. | "SIGINFO";
  320. type UncaughtExceptionOrigin = "uncaughtException" | "unhandledRejection";
  321. type MultipleResolveType = "resolve" | "reject";
  322. type BeforeExitListener = (code: number) => void;
  323. type DisconnectListener = () => void;
  324. type ExitListener = (code: number) => void;
  325. type RejectionHandledListener = (promise: Promise<unknown>) => void;
  326. type UncaughtExceptionListener = (error: Error, origin: UncaughtExceptionOrigin) => void;
  327. /**
  328. * Most of the time the unhandledRejection will be an Error, but this should not be relied upon
  329. * as *anything* can be thrown/rejected, it is therefore unsafe to assume that the value is an Error.
  330. */
  331. type UnhandledRejectionListener = (reason: unknown, promise: Promise<unknown>) => void;
  332. type WarningListener = (warning: Error) => void;
  333. type MessageListener = (message: unknown, sendHandle: unknown) => void;
  334. type SignalsListener = (signal: Signals) => void;
  335. type MultipleResolveListener = (
  336. type: MultipleResolveType,
  337. promise: Promise<unknown>,
  338. value: unknown,
  339. ) => void;
  340. type WorkerListener = (worker: Worker) => void;
  341. interface Socket extends ReadWriteStream {
  342. isTTY?: true | undefined;
  343. }
  344. // Alias for compatibility
  345. interface ProcessEnv extends Dict<string> {
  346. /**
  347. * Can be used to change the default timezone at runtime
  348. */
  349. TZ?: string;
  350. }
  351. interface HRTime {
  352. /**
  353. * This is the legacy version of {@link process.hrtime.bigint()}
  354. * before bigint was introduced in JavaScript.
  355. *
  356. * The `process.hrtime()` method returns the current high-resolution real time in a `[seconds, nanoseconds]` tuple `Array`,
  357. * where `nanoseconds` is the remaining part of the real time that can't be represented in second precision.
  358. *
  359. * `time` is an optional parameter that must be the result of a previous `process.hrtime()` call to diff with the current time.
  360. * If the parameter passed in is not a tuple `Array`, a TypeError will be thrown.
  361. * Passing in a user-defined array instead of the result of a previous call to `process.hrtime()` will lead to undefined behavior.
  362. *
  363. * These times are relative to an arbitrary time in the past,
  364. * and not related to the time of day and therefore not subject to clock drift.
  365. * The primary use is for measuring performance between intervals:
  366. * ```js
  367. * const { hrtime } = require('node:process');
  368. * const NS_PER_SEC = 1e9;
  369. * const time = hrtime();
  370. * // [ 1800216, 25 ]
  371. *
  372. * setTimeout(() => {
  373. * const diff = hrtime(time);
  374. * // [ 1, 552 ]
  375. *
  376. * console.log(`Benchmark took ${diff[0] * NS_PER_SEC + diff[1]} nanoseconds`);
  377. * // Benchmark took 1000000552 nanoseconds
  378. * }, 1000);
  379. * ```
  380. * @since 0.7.6
  381. * @legacy Use {@link process.hrtime.bigint()} instead.
  382. * @param time The result of a previous call to `process.hrtime()`
  383. */
  384. (time?: [number, number]): [number, number];
  385. /**
  386. * The `bigint` version of the {@link process.hrtime()} method returning the current high-resolution real time in nanoseconds as a `bigint`.
  387. *
  388. * Unlike {@link process.hrtime()}, it does not support an additional time argument since the difference can just be computed directly by subtraction of the two `bigint`s.
  389. * ```js
  390. * import { hrtime } from 'node:process';
  391. *
  392. * const start = hrtime.bigint();
  393. * // 191051479007711n
  394. *
  395. * setTimeout(() => {
  396. * const end = hrtime.bigint();
  397. * // 191052633396993n
  398. *
  399. * console.log(`Benchmark took ${end - start} nanoseconds`);
  400. * // Benchmark took 1154389282 nanoseconds
  401. * }, 1000);
  402. * ```
  403. * @since v10.7.0
  404. */
  405. bigint(): bigint;
  406. }
  407. interface ProcessPermission {
  408. /**
  409. * Verifies that the process is able to access the given scope and reference.
  410. * If no reference is provided, a global scope is assumed, for instance, `process.permission.has('fs.read')`
  411. * will check if the process has ALL file system read permissions.
  412. *
  413. * The reference has a meaning based on the provided scope. For example, the reference when the scope is File System means files and folders.
  414. *
  415. * The available scopes are:
  416. *
  417. * * `fs` - All File System
  418. * * `fs.read` - File System read operations
  419. * * `fs.write` - File System write operations
  420. * * `child` - Child process spawning operations
  421. * * `worker` - Worker thread spawning operation
  422. *
  423. * ```js
  424. * // Check if the process has permission to read the README file
  425. * process.permission.has('fs.read', './README.md');
  426. * // Check if the process has read permission operations
  427. * process.permission.has('fs.read');
  428. * ```
  429. * @since v20.0.0
  430. */
  431. has(scope: string, reference?: string): boolean;
  432. }
  433. interface ProcessReport {
  434. /**
  435. * Write reports in a compact format, single-line JSON, more easily consumable by log processing systems
  436. * than the default multi-line format designed for human consumption.
  437. * @since v13.12.0, v12.17.0
  438. */
  439. compact: boolean;
  440. /**
  441. * Directory where the report is written.
  442. * The default value is the empty string, indicating that reports are written to the current
  443. * working directory of the Node.js process.
  444. */
  445. directory: string;
  446. /**
  447. * Filename where the report is written. If set to the empty string, the output filename will be comprised
  448. * of a timestamp, PID, and sequence number. The default value is the empty string.
  449. */
  450. filename: string;
  451. /**
  452. * Returns a JavaScript Object representation of a diagnostic report for the running process.
  453. * The report's JavaScript stack trace is taken from `err`, if present.
  454. */
  455. getReport(err?: Error): object;
  456. /**
  457. * If true, a diagnostic report is generated on fatal errors,
  458. * such as out of memory errors or failed C++ assertions.
  459. * @default false
  460. */
  461. reportOnFatalError: boolean;
  462. /**
  463. * If true, a diagnostic report is generated when the process
  464. * receives the signal specified by process.report.signal.
  465. * @default false
  466. */
  467. reportOnSignal: boolean;
  468. /**
  469. * If true, a diagnostic report is generated on uncaught exception.
  470. * @default false
  471. */
  472. reportOnUncaughtException: boolean;
  473. /**
  474. * The signal used to trigger the creation of a diagnostic report.
  475. * @default 'SIGUSR2'
  476. */
  477. signal: Signals;
  478. /**
  479. * Writes a diagnostic report to a file. If filename is not provided, the default filename
  480. * includes the date, time, PID, and a sequence number.
  481. * The report's JavaScript stack trace is taken from `err`, if present.
  482. *
  483. * If the value of filename is set to `'stdout'` or `'stderr'`, the report is written
  484. * to the stdout or stderr of the process respectively.
  485. * @param fileName Name of the file where the report is written.
  486. * This should be a relative path, that will be appended to the directory specified in
  487. * `process.report.directory`, or the current working directory of the Node.js process,
  488. * if unspecified.
  489. * @param err A custom error used for reporting the JavaScript stack.
  490. * @return Filename of the generated report.
  491. */
  492. writeReport(fileName?: string, err?: Error): string;
  493. writeReport(err?: Error): string;
  494. }
  495. interface ResourceUsage {
  496. fsRead: number;
  497. fsWrite: number;
  498. involuntaryContextSwitches: number;
  499. ipcReceived: number;
  500. ipcSent: number;
  501. majorPageFault: number;
  502. maxRSS: number;
  503. minorPageFault: number;
  504. sharedMemorySize: number;
  505. signalsCount: number;
  506. swappedOut: number;
  507. systemCPUTime: number;
  508. unsharedDataSize: number;
  509. unsharedStackSize: number;
  510. userCPUTime: number;
  511. voluntaryContextSwitches: number;
  512. }
  513. interface EmitWarningOptions {
  514. /**
  515. * When `warning` is a `string`, `type` is the name to use for the _type_ of warning being emitted.
  516. *
  517. * @default 'Warning'
  518. */
  519. type?: string | undefined;
  520. /**
  521. * A unique identifier for the warning instance being emitted.
  522. */
  523. code?: string | undefined;
  524. /**
  525. * When `warning` is a `string`, `ctor` is an optional function used to limit the generated stack trace.
  526. *
  527. * @default process.emitWarning
  528. */
  529. ctor?: Function | undefined;
  530. /**
  531. * Additional text to include with the error.
  532. */
  533. detail?: string | undefined;
  534. }
  535. interface ProcessConfig {
  536. readonly target_defaults: {
  537. readonly cflags: any[];
  538. readonly default_configuration: string;
  539. readonly defines: string[];
  540. readonly include_dirs: string[];
  541. readonly libraries: string[];
  542. };
  543. readonly variables: {
  544. readonly clang: number;
  545. readonly host_arch: string;
  546. readonly node_install_npm: boolean;
  547. readonly node_install_waf: boolean;
  548. readonly node_prefix: string;
  549. readonly node_shared_openssl: boolean;
  550. readonly node_shared_v8: boolean;
  551. readonly node_shared_zlib: boolean;
  552. readonly node_use_dtrace: boolean;
  553. readonly node_use_etw: boolean;
  554. readonly node_use_openssl: boolean;
  555. readonly target_arch: string;
  556. readonly v8_no_strict_aliasing: number;
  557. readonly v8_use_snapshot: boolean;
  558. readonly visibility: string;
  559. };
  560. }
  561. interface Process extends EventEmitter {
  562. /**
  563. * The `process.stdout` property returns a stream connected to`stdout` (fd `1`). It is a `net.Socket` (which is a `Duplex` stream) unless fd `1` refers to a file, in which case it is
  564. * a `Writable` stream.
  565. *
  566. * For example, to copy `process.stdin` to `process.stdout`:
  567. *
  568. * ```js
  569. * import { stdin, stdout } from 'node:process';
  570. *
  571. * stdin.pipe(stdout);
  572. * ```
  573. *
  574. * `process.stdout` differs from other Node.js streams in important ways. See `note on process I/O` for more information.
  575. */
  576. stdout: WriteStream & {
  577. fd: 1;
  578. };
  579. /**
  580. * The `process.stderr` property returns a stream connected to`stderr` (fd `2`). It is a `net.Socket` (which is a `Duplex` stream) unless fd `2` refers to a file, in which case it is
  581. * a `Writable` stream.
  582. *
  583. * `process.stderr` differs from other Node.js streams in important ways. See `note on process I/O` for more information.
  584. */
  585. stderr: WriteStream & {
  586. fd: 2;
  587. };
  588. /**
  589. * The `process.stdin` property returns a stream connected to`stdin` (fd `0`). It is a `net.Socket` (which is a `Duplex` stream) unless fd `0` refers to a file, in which case it is
  590. * a `Readable` stream.
  591. *
  592. * For details of how to read from `stdin` see `readable.read()`.
  593. *
  594. * As a `Duplex` stream, `process.stdin` can also be used in "old" mode that
  595. * is compatible with scripts written for Node.js prior to v0.10\.
  596. * For more information see `Stream compatibility`.
  597. *
  598. * In "old" streams mode the `stdin` stream is paused by default, so one
  599. * must call `process.stdin.resume()` to read from it. Note also that calling `process.stdin.resume()` itself would switch stream to "old" mode.
  600. */
  601. stdin: ReadStream & {
  602. fd: 0;
  603. };
  604. /**
  605. * The `process.argv` property returns an array containing the command-line
  606. * arguments passed when the Node.js process was launched. The first element will
  607. * be {@link execPath}. See `process.argv0` if access to the original value
  608. * of `argv[0]` is needed. The second element will be the path to the JavaScript
  609. * file being executed. The remaining elements will be any additional command-line
  610. * arguments.
  611. *
  612. * For example, assuming the following script for `process-args.js`:
  613. *
  614. * ```js
  615. * import { argv } from 'node:process';
  616. *
  617. * // print process.argv
  618. * argv.forEach((val, index) => {
  619. * console.log(`${index}: ${val}`);
  620. * });
  621. * ```
  622. *
  623. * Launching the Node.js process as:
  624. *
  625. * ```bash
  626. * node process-args.js one two=three four
  627. * ```
  628. *
  629. * Would generate the output:
  630. *
  631. * ```text
  632. * 0: /usr/local/bin/node
  633. * 1: /Users/mjr/work/node/process-args.js
  634. * 2: one
  635. * 3: two=three
  636. * 4: four
  637. * ```
  638. * @since v0.1.27
  639. */
  640. argv: string[];
  641. /**
  642. * The `process.argv0` property stores a read-only copy of the original value of`argv[0]` passed when Node.js starts.
  643. *
  644. * ```console
  645. * $ bash -c 'exec -a customArgv0 ./node'
  646. * > process.argv[0]
  647. * '/Volumes/code/external/node/out/Release/node'
  648. * > process.argv0
  649. * 'customArgv0'
  650. * ```
  651. * @since v6.4.0
  652. */
  653. argv0: string;
  654. /**
  655. * The `process.execArgv` property returns the set of Node.js-specific command-line
  656. * options passed when the Node.js process was launched. These options do not
  657. * appear in the array returned by the {@link argv} property, and do not
  658. * include the Node.js executable, the name of the script, or any options following
  659. * the script name. These options are useful in order to spawn child processes with
  660. * the same execution environment as the parent.
  661. *
  662. * ```bash
  663. * node --icu-data-dir=./foo --require ./bar.js script.js --version
  664. * ```
  665. *
  666. * Results in `process.execArgv`:
  667. *
  668. * ```js
  669. * ["--icu-data-dir=./foo", "--require", "./bar.js"]
  670. * ```
  671. *
  672. * And `process.argv`:
  673. *
  674. * ```js
  675. * ['/usr/local/bin/node', 'script.js', '--version']
  676. * ```
  677. *
  678. * Refer to `Worker constructor` for the detailed behavior of worker
  679. * threads with this property.
  680. * @since v0.7.7
  681. */
  682. execArgv: string[];
  683. /**
  684. * The `process.execPath` property returns the absolute pathname of the executable
  685. * that started the Node.js process. Symbolic links, if any, are resolved.
  686. *
  687. * ```js
  688. * '/usr/local/bin/node'
  689. * ```
  690. * @since v0.1.100
  691. */
  692. execPath: string;
  693. /**
  694. * The `process.abort()` method causes the Node.js process to exit immediately and
  695. * generate a core file.
  696. *
  697. * This feature is not available in `Worker` threads.
  698. * @since v0.7.0
  699. */
  700. abort(): never;
  701. /**
  702. * The `process.chdir()` method changes the current working directory of the
  703. * Node.js process or throws an exception if doing so fails (for instance, if
  704. * the specified `directory` does not exist).
  705. *
  706. * ```js
  707. * import { chdir, cwd } from 'node:process';
  708. *
  709. * console.log(`Starting directory: ${cwd()}`);
  710. * try {
  711. * chdir('/tmp');
  712. * console.log(`New directory: ${cwd()}`);
  713. * } catch (err) {
  714. * console.error(`chdir: ${err}`);
  715. * }
  716. * ```
  717. *
  718. * This feature is not available in `Worker` threads.
  719. * @since v0.1.17
  720. */
  721. chdir(directory: string): void;
  722. /**
  723. * The `process.cwd()` method returns the current working directory of the Node.js
  724. * process.
  725. *
  726. * ```js
  727. * import { cwd } from 'node:process';
  728. *
  729. * console.log(`Current directory: ${cwd()}`);
  730. * ```
  731. * @since v0.1.8
  732. */
  733. cwd(): string;
  734. /**
  735. * The port used by the Node.js debugger when enabled.
  736. *
  737. * ```js
  738. * import process from 'node:process';
  739. *
  740. * process.debugPort = 5858;
  741. * ```
  742. * @since v0.7.2
  743. */
  744. debugPort: number;
  745. /**
  746. * The `process.dlopen()` method allows dynamically loading shared objects. It is primarily used by `require()` to load C++ Addons, and
  747. * should not be used directly, except in special cases. In other words, `require()` should be preferred over `process.dlopen()`
  748. * unless there are specific reasons such as custom dlopen flags or loading from ES modules.
  749. *
  750. * The `flags` argument is an integer that allows to specify dlopen behavior. See the `[os.constants.dlopen](https://nodejs.org/docs/latest-v22.x/api/os.html#dlopen-constants)`
  751. * documentation for details.
  752. *
  753. * An important requirement when calling `process.dlopen()` is that the `module` instance must be passed. Functions exported by the C++ Addon
  754. * are then accessible via `module.exports`.
  755. *
  756. * The example below shows how to load a C++ Addon, named `local.node`, that exports a `foo` function. All the symbols are loaded before the call returns, by passing the `RTLD_NOW` constant.
  757. * In this example the constant is assumed to be available.
  758. *
  759. * ```js
  760. * import { dlopen } from 'node:process';
  761. * import { constants } from 'node:os';
  762. * import { fileURLToPath } from 'node:url';
  763. *
  764. * const module = { exports: {} };
  765. * dlopen(module, fileURLToPath(new URL('local.node', import.meta.url)),
  766. * constants.dlopen.RTLD_NOW);
  767. * module.exports.foo();
  768. * ```
  769. */
  770. dlopen(module: object, filename: string, flags?: number): void;
  771. /**
  772. * The `process.emitWarning()` method can be used to emit custom or application
  773. * specific process warnings. These can be listened for by adding a handler to the `'warning'` event.
  774. *
  775. * ```js
  776. * import { emitWarning } from 'node:process';
  777. *
  778. * // Emit a warning using a string.
  779. * emitWarning('Something happened!');
  780. * // Emits: (node: 56338) Warning: Something happened!
  781. * ```
  782. *
  783. * ```js
  784. * import { emitWarning } from 'node:process';
  785. *
  786. * // Emit a warning using a string and a type.
  787. * emitWarning('Something Happened!', 'CustomWarning');
  788. * // Emits: (node:56338) CustomWarning: Something Happened!
  789. * ```
  790. *
  791. * ```js
  792. * import { emitWarning } from 'node:process';
  793. *
  794. * emitWarning('Something happened!', 'CustomWarning', 'WARN001');
  795. * // Emits: (node:56338) [WARN001] CustomWarning: Something happened!
  796. * ```js
  797. *
  798. * In each of the previous examples, an `Error` object is generated internally by `process.emitWarning()` and passed through to the `'warning'` handler.
  799. *
  800. * ```js
  801. * import process from 'node:process';
  802. *
  803. * process.on('warning', (warning) => {
  804. * console.warn(warning.name); // 'Warning'
  805. * console.warn(warning.message); // 'Something happened!'
  806. * console.warn(warning.code); // 'MY_WARNING'
  807. * console.warn(warning.stack); // Stack trace
  808. * console.warn(warning.detail); // 'This is some additional information'
  809. * });
  810. * ```
  811. *
  812. * If `warning` is passed as an `Error` object, it will be passed through to the `'warning'` event handler
  813. * unmodified (and the optional `type`, `code` and `ctor` arguments will be ignored):
  814. *
  815. * ```js
  816. * import { emitWarning } from 'node:process';
  817. *
  818. * // Emit a warning using an Error object.
  819. * const myWarning = new Error('Something happened!');
  820. * // Use the Error name property to specify the type name
  821. * myWarning.name = 'CustomWarning';
  822. * myWarning.code = 'WARN001';
  823. *
  824. * emitWarning(myWarning);
  825. * // Emits: (node:56338) [WARN001] CustomWarning: Something happened!
  826. * ```
  827. *
  828. * A `TypeError` is thrown if `warning` is anything other than a string or `Error` object.
  829. *
  830. * While process warnings use `Error` objects, the process warning mechanism is not a replacement for normal error handling mechanisms.
  831. *
  832. * The following additional handling is implemented if the warning `type` is `'DeprecationWarning'`:
  833. * * If the `--throw-deprecation` command-line flag is used, the deprecation warning is thrown as an exception rather than being emitted as an event.
  834. * * If the `--no-deprecation` command-line flag is used, the deprecation warning is suppressed.
  835. * * If the `--trace-deprecation` command-line flag is used, the deprecation warning is printed to `stderr` along with the full stack trace.
  836. * @since v8.0.0
  837. * @param warning The warning to emit.
  838. */
  839. emitWarning(warning: string | Error, ctor?: Function): void;
  840. emitWarning(warning: string | Error, type?: string, ctor?: Function): void;
  841. emitWarning(warning: string | Error, type?: string, code?: string, ctor?: Function): void;
  842. emitWarning(warning: string | Error, options?: EmitWarningOptions): void;
  843. /**
  844. * The `process.env` property returns an object containing the user environment.
  845. * See [`environ(7)`](http://man7.org/linux/man-pages/man7/environ.7.html).
  846. *
  847. * An example of this object looks like:
  848. *
  849. * ```js
  850. * {
  851. * TERM: 'xterm-256color',
  852. * SHELL: '/usr/local/bin/bash',
  853. * USER: 'maciej',
  854. * PATH: '~/.bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin',
  855. * PWD: '/Users/maciej',
  856. * EDITOR: 'vim',
  857. * SHLVL: '1',
  858. * HOME: '/Users/maciej',
  859. * LOGNAME: 'maciej',
  860. * _: '/usr/local/bin/node'
  861. * }
  862. * ```
  863. *
  864. * It is possible to modify this object, but such modifications will not be
  865. * reflected outside the Node.js process, or (unless explicitly requested)
  866. * to other `Worker` threads.
  867. * In other words, the following example would not work:
  868. *
  869. * ```bash
  870. * node -e 'process.env.foo = "bar"' &#x26;&#x26; echo $foo
  871. * ```
  872. *
  873. * While the following will:
  874. *
  875. * ```js
  876. * import { env } from 'node:process';
  877. *
  878. * env.foo = 'bar';
  879. * console.log(env.foo);
  880. * ```
  881. *
  882. * Assigning a property on `process.env` will implicitly convert the value
  883. * to a string. **This behavior is deprecated.** Future versions of Node.js may
  884. * throw an error when the value is not a string, number, or boolean.
  885. *
  886. * ```js
  887. * import { env } from 'node:process';
  888. *
  889. * env.test = null;
  890. * console.log(env.test);
  891. * // => 'null'
  892. * env.test = undefined;
  893. * console.log(env.test);
  894. * // => 'undefined'
  895. * ```
  896. *
  897. * Use `delete` to delete a property from `process.env`.
  898. *
  899. * ```js
  900. * import { env } from 'node:process';
  901. *
  902. * env.TEST = 1;
  903. * delete env.TEST;
  904. * console.log(env.TEST);
  905. * // => undefined
  906. * ```
  907. *
  908. * On Windows operating systems, environment variables are case-insensitive.
  909. *
  910. * ```js
  911. * import { env } from 'node:process';
  912. *
  913. * env.TEST = 1;
  914. * console.log(env.test);
  915. * // => 1
  916. * ```
  917. *
  918. * Unless explicitly specified when creating a `Worker` instance,
  919. * each `Worker` thread has its own copy of `process.env`, based on its
  920. * parent thread's `process.env`, or whatever was specified as the `env` option
  921. * to the `Worker` constructor. Changes to `process.env` will not be visible
  922. * across `Worker` threads, and only the main thread can make changes that
  923. * are visible to the operating system or to native add-ons. On Windows, a copy of `process.env` on a `Worker` instance operates in a case-sensitive manner
  924. * unlike the main thread.
  925. * @since v0.1.27
  926. */
  927. env: ProcessEnv;
  928. /**
  929. * The `process.exit()` method instructs Node.js to terminate the process
  930. * synchronously with an exit status of `code`. If `code` is omitted, exit uses
  931. * either the 'success' code `0` or the value of `process.exitCode` if it has been
  932. * set. Node.js will not terminate until all the `'exit'` event listeners are
  933. * called.
  934. *
  935. * To exit with a 'failure' code:
  936. *
  937. * ```js
  938. * import { exit } from 'node:process';
  939. *
  940. * exit(1);
  941. * ```
  942. *
  943. * The shell that executed Node.js should see the exit code as `1`.
  944. *
  945. * Calling `process.exit()` will force the process to exit as quickly as possible
  946. * even if there are still asynchronous operations pending that have not yet
  947. * completed fully, including I/O operations to `process.stdout` and `process.stderr`.
  948. *
  949. * In most situations, it is not actually necessary to call `process.exit()` explicitly. The Node.js process will exit on its own _if there is no additional_
  950. * _work pending_ in the event loop. The `process.exitCode` property can be set to
  951. * tell the process which exit code to use when the process exits gracefully.
  952. *
  953. * For instance, the following example illustrates a _misuse_ of the `process.exit()` method that could lead to data printed to stdout being
  954. * truncated and lost:
  955. *
  956. * ```js
  957. * import { exit } from 'node:process';
  958. *
  959. * // This is an example of what *not* to do:
  960. * if (someConditionNotMet()) {
  961. * printUsageToStdout();
  962. * exit(1);
  963. * }
  964. * ```
  965. *
  966. * The reason this is problematic is because writes to `process.stdout` in Node.js
  967. * are sometimes _asynchronous_ and may occur over multiple ticks of the Node.js
  968. * event loop. Calling `process.exit()`, however, forces the process to exit _before_ those additional writes to `stdout` can be performed.
  969. *
  970. * Rather than calling `process.exit()` directly, the code _should_ set the `process.exitCode` and allow the process to exit naturally by avoiding
  971. * scheduling any additional work for the event loop:
  972. *
  973. * ```js
  974. * import process from 'node:process';
  975. *
  976. * // How to properly set the exit code while letting
  977. * // the process exit gracefully.
  978. * if (someConditionNotMet()) {
  979. * printUsageToStdout();
  980. * process.exitCode = 1;
  981. * }
  982. * ```
  983. *
  984. * If it is necessary to terminate the Node.js process due to an error condition,
  985. * throwing an _uncaught_ error and allowing the process to terminate accordingly
  986. * is safer than calling `process.exit()`.
  987. *
  988. * In `Worker` threads, this function stops the current thread rather
  989. * than the current process.
  990. * @since v0.1.13
  991. * @param [code=0] The exit code. For string type, only integer strings (e.g.,'1') are allowed.
  992. */
  993. exit(code?: number | string | null | undefined): never;
  994. /**
  995. * A number which will be the process exit code, when the process either
  996. * exits gracefully, or is exited via {@link exit} without specifying
  997. * a code.
  998. *
  999. * Specifying a code to {@link exit} will override any
  1000. * previous setting of `process.exitCode`.
  1001. * @default undefined
  1002. * @since v0.11.8
  1003. */
  1004. exitCode?: number | string | number | undefined;
  1005. finalization: {
  1006. /**
  1007. * This function registers a callback to be called when the process emits the `exit` event if the `ref` object was not garbage collected.
  1008. * If the object `ref` was garbage collected before the `exit` event is emitted, the callback will be removed from the finalization registry, and it will not be called on process exit.
  1009. *
  1010. * Inside the callback you can release the resources allocated by the `ref` object.
  1011. * Be aware that all limitations applied to the `beforeExit` event are also applied to the callback function,
  1012. * this means that there is a possibility that the callback will not be called under special circumstances.
  1013. *
  1014. * The idea of ​​this function is to help you free up resources when the starts process exiting, but also let the object be garbage collected if it is no longer being used.
  1015. * @param ref The reference to the resource that is being tracked.
  1016. * @param callback The callback function to be called when the resource is finalized.
  1017. * @since v22.5.0
  1018. * @experimental
  1019. */
  1020. register<T extends object>(ref: T, callback: (ref: T, event: "exit") => void): void;
  1021. /**
  1022. * This function behaves exactly like the `register`, except that the callback will be called when the process emits the `beforeExit` event if `ref` object was not garbage collected.
  1023. *
  1024. * Be aware that all limitations applied to the `beforeExit` event are also applied to the callback function, this means that there is a possibility that the callback will not be called under special circumstances.
  1025. * @param ref The reference to the resource that is being tracked.
  1026. * @param callback The callback function to be called when the resource is finalized.
  1027. * @since v22.5.0
  1028. * @experimental
  1029. */
  1030. registerBeforeExit<T extends object>(ref: T, callback: (ref: T, event: "beforeExit") => void): void;
  1031. /**
  1032. * This function remove the register of the object from the finalization registry, so the callback will not be called anymore.
  1033. * @param ref The reference to the resource that was registered previously.
  1034. * @since v22.5.0
  1035. * @experimental
  1036. */
  1037. unregister(ref: object): void;
  1038. };
  1039. /**
  1040. * The `process.getActiveResourcesInfo()` method returns an array of strings containing
  1041. * the types of the active resources that are currently keeping the event loop alive.
  1042. *
  1043. * ```js
  1044. * import { getActiveResourcesInfo } from 'node:process';
  1045. * import { setTimeout } from 'node:timers';
  1046. * console.log('Before:', getActiveResourcesInfo());
  1047. * setTimeout(() => {}, 1000);
  1048. * console.log('After:', getActiveResourcesInfo());
  1049. * // Prints:
  1050. * // Before: [ 'TTYWrap', 'TTYWrap', 'TTYWrap' ]
  1051. * // After: [ 'TTYWrap', 'TTYWrap', 'TTYWrap', 'Timeout' ]
  1052. * ```
  1053. * @since v17.3.0, v16.14.0
  1054. */
  1055. getActiveResourcesInfo(): string[];
  1056. /**
  1057. * Provides a way to load built-in modules in a globally available function.
  1058. * @param id ID of the built-in module being requested.
  1059. */
  1060. getBuiltinModule<ID extends keyof BuiltInModule>(id: ID): BuiltInModule[ID];
  1061. getBuiltinModule(id: string): object | undefined;
  1062. /**
  1063. * The `process.getgid()` method returns the numerical group identity of the
  1064. * process. (See [`getgid(2)`](http://man7.org/linux/man-pages/man2/getgid.2.html).)
  1065. *
  1066. * ```js
  1067. * import process from 'node:process';
  1068. *
  1069. * if (process.getgid) {
  1070. * console.log(`Current gid: ${process.getgid()}`);
  1071. * }
  1072. * ```
  1073. *
  1074. * This function is only available on POSIX platforms (i.e. not Windows or
  1075. * Android).
  1076. * @since v0.1.31
  1077. */
  1078. getgid?: () => number;
  1079. /**
  1080. * The `process.setgid()` method sets the group identity of the process. (See [`setgid(2)`](http://man7.org/linux/man-pages/man2/setgid.2.html).) The `id` can be passed as either a
  1081. * numeric ID or a group name
  1082. * string. If a group name is specified, this method blocks while resolving the
  1083. * associated numeric ID.
  1084. *
  1085. * ```js
  1086. * import process from 'node:process';
  1087. *
  1088. * if (process.getgid &#x26;&#x26; process.setgid) {
  1089. * console.log(`Current gid: ${process.getgid()}`);
  1090. * try {
  1091. * process.setgid(501);
  1092. * console.log(`New gid: ${process.getgid()}`);
  1093. * } catch (err) {
  1094. * console.log(`Failed to set gid: ${err}`);
  1095. * }
  1096. * }
  1097. * ```
  1098. *
  1099. * This function is only available on POSIX platforms (i.e. not Windows or
  1100. * Android).
  1101. * This feature is not available in `Worker` threads.
  1102. * @since v0.1.31
  1103. * @param id The group name or ID
  1104. */
  1105. setgid?: (id: number | string) => void;
  1106. /**
  1107. * The `process.getuid()` method returns the numeric user identity of the process.
  1108. * (See [`getuid(2)`](http://man7.org/linux/man-pages/man2/getuid.2.html).)
  1109. *
  1110. * ```js
  1111. * import process from 'node:process';
  1112. *
  1113. * if (process.getuid) {
  1114. * console.log(`Current uid: ${process.getuid()}`);
  1115. * }
  1116. * ```
  1117. *
  1118. * This function is only available on POSIX platforms (i.e. not Windows or
  1119. * Android).
  1120. * @since v0.1.28
  1121. */
  1122. getuid?: () => number;
  1123. /**
  1124. * The `process.setuid(id)` method sets the user identity of the process. (See [`setuid(2)`](http://man7.org/linux/man-pages/man2/setuid.2.html).) The `id` can be passed as either a
  1125. * numeric ID or a username string.
  1126. * If a username is specified, the method blocks while resolving the associated
  1127. * numeric ID.
  1128. *
  1129. * ```js
  1130. * import process from 'node:process';
  1131. *
  1132. * if (process.getuid &#x26;&#x26; process.setuid) {
  1133. * console.log(`Current uid: ${process.getuid()}`);
  1134. * try {
  1135. * process.setuid(501);
  1136. * console.log(`New uid: ${process.getuid()}`);
  1137. * } catch (err) {
  1138. * console.log(`Failed to set uid: ${err}`);
  1139. * }
  1140. * }
  1141. * ```
  1142. *
  1143. * This function is only available on POSIX platforms (i.e. not Windows or
  1144. * Android).
  1145. * This feature is not available in `Worker` threads.
  1146. * @since v0.1.28
  1147. */
  1148. setuid?: (id: number | string) => void;
  1149. /**
  1150. * The `process.geteuid()` method returns the numerical effective user identity of
  1151. * the process. (See [`geteuid(2)`](http://man7.org/linux/man-pages/man2/geteuid.2.html).)
  1152. *
  1153. * ```js
  1154. * import process from 'node:process';
  1155. *
  1156. * if (process.geteuid) {
  1157. * console.log(`Current uid: ${process.geteuid()}`);
  1158. * }
  1159. * ```
  1160. *
  1161. * This function is only available on POSIX platforms (i.e. not Windows or
  1162. * Android).
  1163. * @since v2.0.0
  1164. */
  1165. geteuid?: () => number;
  1166. /**
  1167. * The `process.seteuid()` method sets the effective user identity of the process.
  1168. * (See [`seteuid(2)`](http://man7.org/linux/man-pages/man2/seteuid.2.html).) The `id` can be passed as either a numeric ID or a username
  1169. * string. If a username is specified, the method blocks while resolving the
  1170. * associated numeric ID.
  1171. *
  1172. * ```js
  1173. * import process from 'node:process';
  1174. *
  1175. * if (process.geteuid &#x26;&#x26; process.seteuid) {
  1176. * console.log(`Current uid: ${process.geteuid()}`);
  1177. * try {
  1178. * process.seteuid(501);
  1179. * console.log(`New uid: ${process.geteuid()}`);
  1180. * } catch (err) {
  1181. * console.log(`Failed to set uid: ${err}`);
  1182. * }
  1183. * }
  1184. * ```
  1185. *
  1186. * This function is only available on POSIX platforms (i.e. not Windows or
  1187. * Android).
  1188. * This feature is not available in `Worker` threads.
  1189. * @since v2.0.0
  1190. * @param id A user name or ID
  1191. */
  1192. seteuid?: (id: number | string) => void;
  1193. /**
  1194. * The `process.getegid()` method returns the numerical effective group identity
  1195. * of the Node.js process. (See [`getegid(2)`](http://man7.org/linux/man-pages/man2/getegid.2.html).)
  1196. *
  1197. * ```js
  1198. * import process from 'node:process';
  1199. *
  1200. * if (process.getegid) {
  1201. * console.log(`Current gid: ${process.getegid()}`);
  1202. * }
  1203. * ```
  1204. *
  1205. * This function is only available on POSIX platforms (i.e. not Windows or
  1206. * Android).
  1207. * @since v2.0.0
  1208. */
  1209. getegid?: () => number;
  1210. /**
  1211. * The `process.setegid()` method sets the effective group identity of the process.
  1212. * (See [`setegid(2)`](http://man7.org/linux/man-pages/man2/setegid.2.html).) The `id` can be passed as either a numeric ID or a group
  1213. * name string. If a group name is specified, this method blocks while resolving
  1214. * the associated a numeric ID.
  1215. *
  1216. * ```js
  1217. * import process from 'node:process';
  1218. *
  1219. * if (process.getegid &#x26;&#x26; process.setegid) {
  1220. * console.log(`Current gid: ${process.getegid()}`);
  1221. * try {
  1222. * process.setegid(501);
  1223. * console.log(`New gid: ${process.getegid()}`);
  1224. * } catch (err) {
  1225. * console.log(`Failed to set gid: ${err}`);
  1226. * }
  1227. * }
  1228. * ```
  1229. *
  1230. * This function is only available on POSIX platforms (i.e. not Windows or
  1231. * Android).
  1232. * This feature is not available in `Worker` threads.
  1233. * @since v2.0.0
  1234. * @param id A group name or ID
  1235. */
  1236. setegid?: (id: number | string) => void;
  1237. /**
  1238. * The `process.getgroups()` method returns an array with the supplementary group
  1239. * IDs. POSIX leaves it unspecified if the effective group ID is included but
  1240. * Node.js ensures it always is.
  1241. *
  1242. * ```js
  1243. * import process from 'node:process';
  1244. *
  1245. * if (process.getgroups) {
  1246. * console.log(process.getgroups()); // [ 16, 21, 297 ]
  1247. * }
  1248. * ```
  1249. *
  1250. * This function is only available on POSIX platforms (i.e. not Windows or
  1251. * Android).
  1252. * @since v0.9.4
  1253. */
  1254. getgroups?: () => number[];
  1255. /**
  1256. * The `process.setgroups()` method sets the supplementary group IDs for the
  1257. * Node.js process. This is a privileged operation that requires the Node.js
  1258. * process to have `root` or the `CAP_SETGID` capability.
  1259. *
  1260. * The `groups` array can contain numeric group IDs, group names, or both.
  1261. *
  1262. * ```js
  1263. * import process from 'node:process';
  1264. *
  1265. * if (process.getgroups &#x26;&#x26; process.setgroups) {
  1266. * try {
  1267. * process.setgroups([501]);
  1268. * console.log(process.getgroups()); // new groups
  1269. * } catch (err) {
  1270. * console.log(`Failed to set groups: ${err}`);
  1271. * }
  1272. * }
  1273. * ```
  1274. *
  1275. * This function is only available on POSIX platforms (i.e. not Windows or
  1276. * Android).
  1277. * This feature is not available in `Worker` threads.
  1278. * @since v0.9.4
  1279. */
  1280. setgroups?: (groups: ReadonlyArray<string | number>) => void;
  1281. /**
  1282. * The `process.setUncaughtExceptionCaptureCallback()` function sets a function
  1283. * that will be invoked when an uncaught exception occurs, which will receive the
  1284. * exception value itself as its first argument.
  1285. *
  1286. * If such a function is set, the `'uncaughtException'` event will
  1287. * not be emitted. If `--abort-on-uncaught-exception` was passed from the
  1288. * command line or set through `v8.setFlagsFromString()`, the process will
  1289. * not abort. Actions configured to take place on exceptions such as report
  1290. * generations will be affected too
  1291. *
  1292. * To unset the capture function, `process.setUncaughtExceptionCaptureCallback(null)` may be used. Calling this
  1293. * method with a non-`null` argument while another capture function is set will
  1294. * throw an error.
  1295. *
  1296. * Using this function is mutually exclusive with using the deprecated `domain` built-in module.
  1297. * @since v9.3.0
  1298. */
  1299. setUncaughtExceptionCaptureCallback(cb: ((err: Error) => void) | null): void;
  1300. /**
  1301. * Indicates whether a callback has been set using {@link setUncaughtExceptionCaptureCallback}.
  1302. * @since v9.3.0
  1303. */
  1304. hasUncaughtExceptionCaptureCallback(): boolean;
  1305. /**
  1306. * The `process.sourceMapsEnabled` property returns whether the [Source Map v3](https://sourcemaps.info/spec.html) support for stack traces is enabled.
  1307. * @since v20.7.0
  1308. * @experimental
  1309. */
  1310. readonly sourceMapsEnabled: boolean;
  1311. /**
  1312. * This function enables or disables the [Source Map v3](https://sourcemaps.info/spec.html) support for
  1313. * stack traces.
  1314. *
  1315. * It provides same features as launching Node.js process with commandline options `--enable-source-maps`.
  1316. *
  1317. * Only source maps in JavaScript files that are loaded after source maps has been
  1318. * enabled will be parsed and loaded.
  1319. * @since v16.6.0, v14.18.0
  1320. * @experimental
  1321. */
  1322. setSourceMapsEnabled(value: boolean): void;
  1323. /**
  1324. * The `process.version` property contains the Node.js version string.
  1325. *
  1326. * ```js
  1327. * import { version } from 'node:process';
  1328. *
  1329. * console.log(`Version: ${version}`);
  1330. * // Version: v14.8.0
  1331. * ```
  1332. *
  1333. * To get the version string without the prepended _v_, use`process.versions.node`.
  1334. * @since v0.1.3
  1335. */
  1336. readonly version: string;
  1337. /**
  1338. * The `process.versions` property returns an object listing the version strings of
  1339. * Node.js and its dependencies. `process.versions.modules` indicates the current
  1340. * ABI version, which is increased whenever a C++ API changes. Node.js will refuse
  1341. * to load modules that were compiled against a different module ABI version.
  1342. *
  1343. * ```js
  1344. * import { versions } from 'node:process';
  1345. *
  1346. * console.log(versions);
  1347. * ```
  1348. *
  1349. * Will generate an object similar to:
  1350. *
  1351. * ```console
  1352. * { node: '20.2.0',
  1353. * acorn: '8.8.2',
  1354. * ada: '2.4.0',
  1355. * ares: '1.19.0',
  1356. * base64: '0.5.0',
  1357. * brotli: '1.0.9',
  1358. * cjs_module_lexer: '1.2.2',
  1359. * cldr: '43.0',
  1360. * icu: '73.1',
  1361. * llhttp: '8.1.0',
  1362. * modules: '115',
  1363. * napi: '8',
  1364. * nghttp2: '1.52.0',
  1365. * nghttp3: '0.7.0',
  1366. * ngtcp2: '0.8.1',
  1367. * openssl: '3.0.8+quic',
  1368. * simdutf: '3.2.9',
  1369. * tz: '2023c',
  1370. * undici: '5.22.0',
  1371. * unicode: '15.0',
  1372. * uv: '1.44.2',
  1373. * uvwasi: '0.0.16',
  1374. * v8: '11.3.244.8-node.9',
  1375. * zlib: '1.2.13' }
  1376. * ```
  1377. * @since v0.2.0
  1378. */
  1379. readonly versions: ProcessVersions;
  1380. /**
  1381. * The `process.config` property returns a frozen `Object` containing the
  1382. * JavaScript representation of the configure options used to compile the current
  1383. * Node.js executable. This is the same as the `config.gypi` file that was produced
  1384. * when running the `./configure` script.
  1385. *
  1386. * An example of the possible output looks like:
  1387. *
  1388. * ```js
  1389. * {
  1390. * target_defaults:
  1391. * { cflags: [],
  1392. * default_configuration: 'Release',
  1393. * defines: [],
  1394. * include_dirs: [],
  1395. * libraries: [] },
  1396. * variables:
  1397. * {
  1398. * host_arch: 'x64',
  1399. * napi_build_version: 5,
  1400. * node_install_npm: 'true',
  1401. * node_prefix: '',
  1402. * node_shared_cares: 'false',
  1403. * node_shared_http_parser: 'false',
  1404. * node_shared_libuv: 'false',
  1405. * node_shared_zlib: 'false',
  1406. * node_use_openssl: 'true',
  1407. * node_shared_openssl: 'false',
  1408. * strict_aliasing: 'true',
  1409. * target_arch: 'x64',
  1410. * v8_use_snapshot: 1
  1411. * }
  1412. * }
  1413. * ```
  1414. * @since v0.7.7
  1415. */
  1416. readonly config: ProcessConfig;
  1417. /**
  1418. * The `process.kill()` method sends the `signal` to the process identified by`pid`.
  1419. *
  1420. * Signal names are strings such as `'SIGINT'` or `'SIGHUP'`. See `Signal Events` and [`kill(2)`](http://man7.org/linux/man-pages/man2/kill.2.html) for more information.
  1421. *
  1422. * This method will throw an error if the target `pid` does not exist. As a special
  1423. * case, a signal of `0` can be used to test for the existence of a process.
  1424. * Windows platforms will throw an error if the `pid` is used to kill a process
  1425. * group.
  1426. *
  1427. * Even though the name of this function is `process.kill()`, it is really just a
  1428. * signal sender, like the `kill` system call. The signal sent may do something
  1429. * other than kill the target process.
  1430. *
  1431. * ```js
  1432. * import process, { kill } from 'node:process';
  1433. *
  1434. * process.on('SIGHUP', () => {
  1435. * console.log('Got SIGHUP signal.');
  1436. * });
  1437. *
  1438. * setTimeout(() => {
  1439. * console.log('Exiting.');
  1440. * process.exit(0);
  1441. * }, 100);
  1442. *
  1443. * kill(process.pid, 'SIGHUP');
  1444. * ```
  1445. *
  1446. * When `SIGUSR1` is received by a Node.js process, Node.js will start the
  1447. * debugger. See `Signal Events`.
  1448. * @since v0.0.6
  1449. * @param pid A process ID
  1450. * @param [signal='SIGTERM'] The signal to send, either as a string or number.
  1451. */
  1452. kill(pid: number, signal?: string | number): true;
  1453. /**
  1454. * Loads the environment configuration from a `.env` file into `process.env`. If
  1455. * the file is not found, error will be thrown.
  1456. *
  1457. * To load a specific .env file by specifying its path, use the following code:
  1458. *
  1459. * ```js
  1460. * import { loadEnvFile } from 'node:process';
  1461. *
  1462. * loadEnvFile('./development.env')
  1463. * ```
  1464. * @since v20.12.0
  1465. * @param path The path to the .env file
  1466. */
  1467. loadEnvFile(path?: string | URL | Buffer): void;
  1468. /**
  1469. * The `process.pid` property returns the PID of the process.
  1470. *
  1471. * ```js
  1472. * import { pid } from 'node:process';
  1473. *
  1474. * console.log(`This process is pid ${pid}`);
  1475. * ```
  1476. * @since v0.1.15
  1477. */
  1478. readonly pid: number;
  1479. /**
  1480. * The `process.ppid` property returns the PID of the parent of the
  1481. * current process.
  1482. *
  1483. * ```js
  1484. * import { ppid } from 'node:process';
  1485. *
  1486. * console.log(`The parent process is pid ${ppid}`);
  1487. * ```
  1488. * @since v9.2.0, v8.10.0, v6.13.0
  1489. */
  1490. readonly ppid: number;
  1491. /**
  1492. * The `process.title` property returns the current process title (i.e. returns
  1493. * the current value of `ps`). Assigning a new value to `process.title` modifies
  1494. * the current value of `ps`.
  1495. *
  1496. * When a new value is assigned, different platforms will impose different maximum
  1497. * length restrictions on the title. Usually such restrictions are quite limited.
  1498. * For instance, on Linux and macOS, `process.title` is limited to the size of the
  1499. * binary name plus the length of the command-line arguments because setting the `process.title` overwrites the `argv` memory of the process. Node.js v0.8
  1500. * allowed for longer process title strings by also overwriting the `environ` memory but that was potentially insecure and confusing in some (rather obscure)
  1501. * cases.
  1502. *
  1503. * Assigning a value to `process.title` might not result in an accurate label
  1504. * within process manager applications such as macOS Activity Monitor or Windows
  1505. * Services Manager.
  1506. * @since v0.1.104
  1507. */
  1508. title: string;
  1509. /**
  1510. * The operating system CPU architecture for which the Node.js binary was compiled.
  1511. * Possible values are: `'arm'`, `'arm64'`, `'ia32'`, `'loong64'`, `'mips'`, `'mipsel'`, `'ppc'`, `'ppc64'`, `'riscv64'`, `'s390'`, `'s390x'`, and `'x64'`.
  1512. *
  1513. * ```js
  1514. * import { arch } from 'node:process';
  1515. *
  1516. * console.log(`This processor architecture is ${arch}`);
  1517. * ```
  1518. * @since v0.5.0
  1519. */
  1520. readonly arch: Architecture;
  1521. /**
  1522. * The `process.platform` property returns a string identifying the operating
  1523. * system platform for which the Node.js binary was compiled.
  1524. *
  1525. * Currently possible values are:
  1526. *
  1527. * * `'aix'`
  1528. * * `'darwin'`
  1529. * * `'freebsd'`
  1530. * * `'linux'`
  1531. * * `'openbsd'`
  1532. * * `'sunos'`
  1533. * * `'win32'`
  1534. *
  1535. * ```js
  1536. * import { platform } from 'node:process';
  1537. *
  1538. * console.log(`This platform is ${platform}`);
  1539. * ```
  1540. *
  1541. * The value `'android'` may also be returned if the Node.js is built on the
  1542. * Android operating system. However, Android support in Node.js [is experimental](https://github.com/nodejs/node/blob/HEAD/BUILDING.md#androidandroid-based-devices-eg-firefox-os).
  1543. * @since v0.1.16
  1544. */
  1545. readonly platform: Platform;
  1546. /**
  1547. * The `process.mainModule` property provides an alternative way of retrieving `require.main`. The difference is that if the main module changes at
  1548. * runtime, `require.main` may still refer to the original main module in
  1549. * modules that were required before the change occurred. Generally, it's
  1550. * safe to assume that the two refer to the same module.
  1551. *
  1552. * As with `require.main`, `process.mainModule` will be `undefined` if there
  1553. * is no entry script.
  1554. * @since v0.1.17
  1555. * @deprecated Since v14.0.0 - Use `main` instead.
  1556. */
  1557. mainModule?: Module | undefined;
  1558. memoryUsage: MemoryUsageFn;
  1559. /**
  1560. * Gets the amount of memory available to the process (in bytes) based on
  1561. * limits imposed by the OS. If there is no such constraint, or the constraint
  1562. * is unknown, `0` is returned.
  1563. *
  1564. * See [`uv_get_constrained_memory`](https://docs.libuv.org/en/v1.x/misc.html#c.uv_get_constrained_memory) for more
  1565. * information.
  1566. * @since v19.6.0, v18.15.0
  1567. * @experimental
  1568. */
  1569. constrainedMemory(): number;
  1570. /**
  1571. * Gets the amount of free memory that is still available to the process (in bytes).
  1572. * See [`uv_get_available_memory`](https://nodejs.org/docs/latest-v22.x/api/process.html#processavailablememory) for more information.
  1573. * @experimental
  1574. * @since v20.13.0
  1575. */
  1576. availableMemory(): number;
  1577. /**
  1578. * The `process.cpuUsage()` method returns the user and system CPU time usage of
  1579. * the current process, in an object with properties `user` and `system`, whose
  1580. * values are microsecond values (millionth of a second). These values measure time
  1581. * spent in user and system code respectively, and may end up being greater than
  1582. * actual elapsed time if multiple CPU cores are performing work for this process.
  1583. *
  1584. * The result of a previous call to `process.cpuUsage()` can be passed as the
  1585. * argument to the function, to get a diff reading.
  1586. *
  1587. * ```js
  1588. * import { cpuUsage } from 'node:process';
  1589. *
  1590. * const startUsage = cpuUsage();
  1591. * // { user: 38579, system: 6986 }
  1592. *
  1593. * // spin the CPU for 500 milliseconds
  1594. * const now = Date.now();
  1595. * while (Date.now() - now < 500);
  1596. *
  1597. * console.log(cpuUsage(startUsage));
  1598. * // { user: 514883, system: 11226 }
  1599. * ```
  1600. * @since v6.1.0
  1601. * @param previousValue A previous return value from calling `process.cpuUsage()`
  1602. */
  1603. cpuUsage(previousValue?: CpuUsage): CpuUsage;
  1604. /**
  1605. * `process.nextTick()` adds `callback` to the "next tick queue". This queue is
  1606. * fully drained after the current operation on the JavaScript stack runs to
  1607. * completion and before the event loop is allowed to continue. It's possible to
  1608. * create an infinite loop if one were to recursively call `process.nextTick()`.
  1609. * See the [Event Loop](https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/#process-nexttick) guide for more background.
  1610. *
  1611. * ```js
  1612. * import { nextTick } from 'node:process';
  1613. *
  1614. * console.log('start');
  1615. * nextTick(() => {
  1616. * console.log('nextTick callback');
  1617. * });
  1618. * console.log('scheduled');
  1619. * // Output:
  1620. * // start
  1621. * // scheduled
  1622. * // nextTick callback
  1623. * ```
  1624. *
  1625. * This is important when developing APIs in order to give users the opportunity
  1626. * to assign event handlers _after_ an object has been constructed but before any
  1627. * I/O has occurred:
  1628. *
  1629. * ```js
  1630. * import { nextTick } from 'node:process';
  1631. *
  1632. * function MyThing(options) {
  1633. * this.setupOptions(options);
  1634. *
  1635. * nextTick(() => {
  1636. * this.startDoingStuff();
  1637. * });
  1638. * }
  1639. *
  1640. * const thing = new MyThing();
  1641. * thing.getReadyForStuff();
  1642. *
  1643. * // thing.startDoingStuff() gets called now, not before.
  1644. * ```
  1645. *
  1646. * It is very important for APIs to be either 100% synchronous or 100%
  1647. * asynchronous. Consider this example:
  1648. *
  1649. * ```js
  1650. * // WARNING! DO NOT USE! BAD UNSAFE HAZARD!
  1651. * function maybeSync(arg, cb) {
  1652. * if (arg) {
  1653. * cb();
  1654. * return;
  1655. * }
  1656. *
  1657. * fs.stat('file', cb);
  1658. * }
  1659. * ```
  1660. *
  1661. * This API is hazardous because in the following case:
  1662. *
  1663. * ```js
  1664. * const maybeTrue = Math.random() > 0.5;
  1665. *
  1666. * maybeSync(maybeTrue, () => {
  1667. * foo();
  1668. * });
  1669. *
  1670. * bar();
  1671. * ```
  1672. *
  1673. * It is not clear whether `foo()` or `bar()` will be called first.
  1674. *
  1675. * The following approach is much better:
  1676. *
  1677. * ```js
  1678. * import { nextTick } from 'node:process';
  1679. *
  1680. * function definitelyAsync(arg, cb) {
  1681. * if (arg) {
  1682. * nextTick(cb);
  1683. * return;
  1684. * }
  1685. *
  1686. * fs.stat('file', cb);
  1687. * }
  1688. * ```
  1689. * @since v0.1.26
  1690. * @param args Additional arguments to pass when invoking the `callback`
  1691. */
  1692. nextTick(callback: Function, ...args: any[]): void;
  1693. /**
  1694. * This API is available through the [--permission](https://nodejs.org/api/cli.html#--permission) flag.
  1695. *
  1696. * `process.permission` is an object whose methods are used to manage permissions for the current process.
  1697. * Additional documentation is available in the [Permission Model](https://nodejs.org/api/permissions.html#permission-model).
  1698. * @since v20.0.0
  1699. */
  1700. permission: ProcessPermission;
  1701. /**
  1702. * The `process.release` property returns an `Object` containing metadata related
  1703. * to the current release, including URLs for the source tarball and headers-only
  1704. * tarball.
  1705. *
  1706. * `process.release` contains the following properties:
  1707. *
  1708. * ```js
  1709. * {
  1710. * name: 'node',
  1711. * lts: 'Hydrogen',
  1712. * sourceUrl: 'https://nodejs.org/download/release/v18.12.0/node-v18.12.0.tar.gz',
  1713. * headersUrl: 'https://nodejs.org/download/release/v18.12.0/node-v18.12.0-headers.tar.gz',
  1714. * libUrl: 'https://nodejs.org/download/release/v18.12.0/win-x64/node.lib'
  1715. * }
  1716. * ```
  1717. *
  1718. * In custom builds from non-release versions of the source tree, only the `name` property may be present. The additional properties should not be
  1719. * relied upon to exist.
  1720. * @since v3.0.0
  1721. */
  1722. readonly release: ProcessRelease;
  1723. readonly features: ProcessFeatures;
  1724. /**
  1725. * `process.umask()` returns the Node.js process's file mode creation mask. Child
  1726. * processes inherit the mask from the parent process.
  1727. * @since v0.1.19
  1728. * @deprecated Calling `process.umask()` with no argument causes the process-wide umask to be written twice. This introduces a race condition between threads, and is a potential
  1729. * security vulnerability. There is no safe, cross-platform alternative API.
  1730. */
  1731. umask(): number;
  1732. /**
  1733. * Can only be set if not in worker thread.
  1734. */
  1735. umask(mask: string | number): number;
  1736. /**
  1737. * The `process.uptime()` method returns the number of seconds the current Node.js
  1738. * process has been running.
  1739. *
  1740. * The return value includes fractions of a second. Use `Math.floor()` to get whole
  1741. * seconds.
  1742. * @since v0.5.0
  1743. */
  1744. uptime(): number;
  1745. hrtime: HRTime;
  1746. /**
  1747. * If the Node.js process was spawned with an IPC channel, the process.channel property is a reference to the IPC channel.
  1748. * If no IPC channel exists, this property is undefined.
  1749. * @since v7.1.0
  1750. */
  1751. channel?: {
  1752. /**
  1753. * This method makes the IPC channel keep the event loop of the process running if .unref() has been called before.
  1754. * @since v7.1.0
  1755. */
  1756. ref(): void;
  1757. /**
  1758. * 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.
  1759. * @since v7.1.0
  1760. */
  1761. unref(): void;
  1762. };
  1763. /**
  1764. * If Node.js is spawned with an IPC channel, the `process.send()` method can be
  1765. * used to send messages to the parent process. Messages will be received as a `'message'` event on the parent's `ChildProcess` object.
  1766. *
  1767. * If Node.js was not spawned with an IPC channel, `process.send` will be `undefined`.
  1768. *
  1769. * The message goes through serialization and parsing. The resulting message might
  1770. * not be the same as what is originally sent.
  1771. * @since v0.5.9
  1772. * @param options used to parameterize the sending of certain types of handles. `options` supports the following properties:
  1773. */
  1774. send?(
  1775. message: any,
  1776. sendHandle?: any,
  1777. options?: {
  1778. keepOpen?: boolean | undefined;
  1779. },
  1780. callback?: (error: Error | null) => void,
  1781. ): boolean;
  1782. /**
  1783. * If the Node.js process is spawned with an IPC channel (see the `Child Process` and `Cluster` documentation), the `process.disconnect()` method will close the
  1784. * IPC channel to the parent process, allowing the child process to exit gracefully
  1785. * once there are no other connections keeping it alive.
  1786. *
  1787. * The effect of calling `process.disconnect()` is the same as calling `ChildProcess.disconnect()` from the parent process.
  1788. *
  1789. * If the Node.js process was not spawned with an IPC channel, `process.disconnect()` will be `undefined`.
  1790. * @since v0.7.2
  1791. */
  1792. disconnect(): void;
  1793. /**
  1794. * If the Node.js process is spawned with an IPC channel (see the `Child Process` and `Cluster` documentation), the `process.connected` property will return `true` so long as the IPC
  1795. * channel is connected and will return `false` after `process.disconnect()` is called.
  1796. *
  1797. * Once `process.connected` is `false`, it is no longer possible to send messages
  1798. * over the IPC channel using `process.send()`.
  1799. * @since v0.7.2
  1800. */
  1801. connected: boolean;
  1802. /**
  1803. * The `process.allowedNodeEnvironmentFlags` property is a special,
  1804. * read-only `Set` of flags allowable within the `NODE_OPTIONS` environment variable.
  1805. *
  1806. * `process.allowedNodeEnvironmentFlags` extends `Set`, but overrides `Set.prototype.has` to recognize several different possible flag
  1807. * representations. `process.allowedNodeEnvironmentFlags.has()` will
  1808. * return `true` in the following cases:
  1809. *
  1810. * * Flags may omit leading single (`-`) or double (`--`) dashes; e.g., `inspect-brk` for `--inspect-brk`, or `r` for `-r`.
  1811. * * Flags passed through to V8 (as listed in `--v8-options`) may replace
  1812. * one or more _non-leading_ dashes for an underscore, or vice-versa;
  1813. * e.g., `--perf_basic_prof`, `--perf-basic-prof`, `--perf_basic-prof`,
  1814. * etc.
  1815. * * Flags may contain one or more equals (`=`) characters; all
  1816. * characters after and including the first equals will be ignored;
  1817. * e.g., `--stack-trace-limit=100`.
  1818. * * Flags _must_ be allowable within `NODE_OPTIONS`.
  1819. *
  1820. * When iterating over `process.allowedNodeEnvironmentFlags`, flags will
  1821. * appear only _once_; each will begin with one or more dashes. Flags
  1822. * passed through to V8 will contain underscores instead of non-leading
  1823. * dashes:
  1824. *
  1825. * ```js
  1826. * import { allowedNodeEnvironmentFlags } from 'node:process';
  1827. *
  1828. * allowedNodeEnvironmentFlags.forEach((flag) => {
  1829. * // -r
  1830. * // --inspect-brk
  1831. * // --abort_on_uncaught_exception
  1832. * // ...
  1833. * });
  1834. * ```
  1835. *
  1836. * The methods `add()`, `clear()`, and `delete()` of`process.allowedNodeEnvironmentFlags` do nothing, and will fail
  1837. * silently.
  1838. *
  1839. * If Node.js was compiled _without_ `NODE_OPTIONS` support (shown in {@link config}), `process.allowedNodeEnvironmentFlags` will
  1840. * contain what _would have_ been allowable.
  1841. * @since v10.10.0
  1842. */
  1843. allowedNodeEnvironmentFlags: ReadonlySet<string>;
  1844. /**
  1845. * `process.report` is an object whose methods are used to generate diagnostic reports for the current process.
  1846. * Additional documentation is available in the [report documentation](https://nodejs.org/docs/latest-v22.x/api/report.html).
  1847. * @since v11.8.0
  1848. */
  1849. report: ProcessReport;
  1850. /**
  1851. * ```js
  1852. * import { resourceUsage } from 'node:process';
  1853. *
  1854. * console.log(resourceUsage());
  1855. * /*
  1856. * Will output:
  1857. * {
  1858. * userCPUTime: 82872,
  1859. * systemCPUTime: 4143,
  1860. * maxRSS: 33164,
  1861. * sharedMemorySize: 0,
  1862. * unsharedDataSize: 0,
  1863. * unsharedStackSize: 0,
  1864. * minorPageFault: 2469,
  1865. * majorPageFault: 0,
  1866. * swappedOut: 0,
  1867. * fsRead: 0,
  1868. * fsWrite: 8,
  1869. * ipcSent: 0,
  1870. * ipcReceived: 0,
  1871. * signalsCount: 0,
  1872. * voluntaryContextSwitches: 79,
  1873. * involuntaryContextSwitches: 1
  1874. * }
  1875. *
  1876. * ```
  1877. * @since v12.6.0
  1878. * @return the resource usage for the current process. All of these values come from the `uv_getrusage` call which returns a [`uv_rusage_t` struct][uv_rusage_t].
  1879. */
  1880. resourceUsage(): ResourceUsage;
  1881. /**
  1882. * The initial value of `process.throwDeprecation` indicates whether the `--throw-deprecation` flag is set on the current Node.js process. `process.throwDeprecation`
  1883. * is mutable, so whether or not deprecation warnings result in errors may be altered at runtime. See the documentation for the 'warning' event and the emitWarning()
  1884. * method for more information.
  1885. *
  1886. * ```bash
  1887. * $ node --throw-deprecation -p "process.throwDeprecation"
  1888. * true
  1889. * $ node -p "process.throwDeprecation"
  1890. * undefined
  1891. * $ node
  1892. * > process.emitWarning('test', 'DeprecationWarning');
  1893. * undefined
  1894. * > (node:26598) DeprecationWarning: test
  1895. * > process.throwDeprecation = true;
  1896. * true
  1897. * > process.emitWarning('test', 'DeprecationWarning');
  1898. * Thrown:
  1899. * [DeprecationWarning: test] { name: 'DeprecationWarning' }
  1900. * ```
  1901. * @since v0.9.12
  1902. */
  1903. throwDeprecation: boolean;
  1904. /**
  1905. * The `process.traceDeprecation` property indicates whether the `--trace-deprecation` flag is set on the current Node.js process. See the
  1906. * documentation for the `'warning' event` and the `emitWarning() method` for more information about this
  1907. * flag's behavior.
  1908. * @since v0.8.0
  1909. */
  1910. traceDeprecation: boolean;
  1911. /**
  1912. * An object is "refable" if it implements the Node.js "Refable protocol".
  1913. * Specifically, this means that the object implements the `Symbol.for('nodejs.ref')`
  1914. * and `Symbol.for('nodejs.unref')` methods. "Ref'd" objects will keep the Node.js
  1915. * event loop alive, while "unref'd" objects will not. Historically, this was
  1916. * implemented by using `ref()` and `unref()` methods directly on the objects.
  1917. * This pattern, however, is being deprecated in favor of the "Refable protocol"
  1918. * in order to better support Web Platform API types whose APIs cannot be modified
  1919. * to add `ref()` and `unref()` methods but still need to support that behavior.
  1920. * @since v22.14.0
  1921. * @experimental
  1922. * @param maybeRefable An object that may be "refable".
  1923. */
  1924. ref(maybeRefable: any): void;
  1925. /**
  1926. * An object is "unrefable" if it implements the Node.js "Refable protocol".
  1927. * Specifically, this means that the object implements the `Symbol.for('nodejs.ref')`
  1928. * and `Symbol.for('nodejs.unref')` methods. "Ref'd" objects will keep the Node.js
  1929. * event loop alive, while "unref'd" objects will not. Historically, this was
  1930. * implemented by using `ref()` and `unref()` methods directly on the objects.
  1931. * This pattern, however, is being deprecated in favor of the "Refable protocol"
  1932. * in order to better support Web Platform API types whose APIs cannot be modified
  1933. * to add `ref()` and `unref()` methods but still need to support that behavior.
  1934. * @since v22.14.0
  1935. * @experimental
  1936. * @param maybeRefable An object that may be "unref'd".
  1937. */
  1938. unref(maybeRefable: any): void;
  1939. /**
  1940. * Replaces the current process with a new process.
  1941. *
  1942. * This is achieved by using the `execve` POSIX function and therefore no memory or other
  1943. * resources from the current process are preserved, except for the standard input,
  1944. * standard output and standard error file descriptor.
  1945. *
  1946. * All other resources are discarded by the system when the processes are swapped, without triggering
  1947. * any exit or close events and without running any cleanup handler.
  1948. *
  1949. * This function will never return, unless an error occurred.
  1950. *
  1951. * This function is not available on Windows or IBM i.
  1952. * @since v22.15.0
  1953. * @experimental
  1954. * @param file The name or path of the executable file to run.
  1955. * @param args List of string arguments. No argument can contain a null-byte (`\u0000`).
  1956. * @param env Environment key-value pairs.
  1957. * No key or value can contain a null-byte (`\u0000`).
  1958. * **Default:** `process.env`.
  1959. */
  1960. execve?(file: string, args?: readonly string[], env?: ProcessEnv): never;
  1961. /* EventEmitter */
  1962. addListener(event: "beforeExit", listener: BeforeExitListener): this;
  1963. addListener(event: "disconnect", listener: DisconnectListener): this;
  1964. addListener(event: "exit", listener: ExitListener): this;
  1965. addListener(event: "rejectionHandled", listener: RejectionHandledListener): this;
  1966. addListener(event: "uncaughtException", listener: UncaughtExceptionListener): this;
  1967. addListener(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
  1968. addListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
  1969. addListener(event: "warning", listener: WarningListener): this;
  1970. addListener(event: "message", listener: MessageListener): this;
  1971. addListener(event: Signals, listener: SignalsListener): this;
  1972. addListener(event: "multipleResolves", listener: MultipleResolveListener): this;
  1973. addListener(event: "worker", listener: WorkerListener): this;
  1974. emit(event: "beforeExit", code: number): boolean;
  1975. emit(event: "disconnect"): boolean;
  1976. emit(event: "exit", code: number): boolean;
  1977. emit(event: "rejectionHandled", promise: Promise<unknown>): boolean;
  1978. emit(event: "uncaughtException", error: Error): boolean;
  1979. emit(event: "uncaughtExceptionMonitor", error: Error): boolean;
  1980. emit(event: "unhandledRejection", reason: unknown, promise: Promise<unknown>): boolean;
  1981. emit(event: "warning", warning: Error): boolean;
  1982. emit(event: "message", message: unknown, sendHandle: unknown): this;
  1983. emit(event: Signals, signal?: Signals): boolean;
  1984. emit(
  1985. event: "multipleResolves",
  1986. type: MultipleResolveType,
  1987. promise: Promise<unknown>,
  1988. value: unknown,
  1989. ): this;
  1990. emit(event: "worker", listener: WorkerListener): this;
  1991. on(event: "beforeExit", listener: BeforeExitListener): this;
  1992. on(event: "disconnect", listener: DisconnectListener): this;
  1993. on(event: "exit", listener: ExitListener): this;
  1994. on(event: "rejectionHandled", listener: RejectionHandledListener): this;
  1995. on(event: "uncaughtException", listener: UncaughtExceptionListener): this;
  1996. on(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
  1997. on(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
  1998. on(event: "warning", listener: WarningListener): this;
  1999. on(event: "message", listener: MessageListener): this;
  2000. on(event: Signals, listener: SignalsListener): this;
  2001. on(event: "multipleResolves", listener: MultipleResolveListener): this;
  2002. on(event: "worker", listener: WorkerListener): this;
  2003. on(event: string | symbol, listener: (...args: any[]) => void): this;
  2004. once(event: "beforeExit", listener: BeforeExitListener): this;
  2005. once(event: "disconnect", listener: DisconnectListener): this;
  2006. once(event: "exit", listener: ExitListener): this;
  2007. once(event: "rejectionHandled", listener: RejectionHandledListener): this;
  2008. once(event: "uncaughtException", listener: UncaughtExceptionListener): this;
  2009. once(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
  2010. once(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
  2011. once(event: "warning", listener: WarningListener): this;
  2012. once(event: "message", listener: MessageListener): this;
  2013. once(event: Signals, listener: SignalsListener): this;
  2014. once(event: "multipleResolves", listener: MultipleResolveListener): this;
  2015. once(event: "worker", listener: WorkerListener): this;
  2016. once(event: string | symbol, listener: (...args: any[]) => void): this;
  2017. prependListener(event: "beforeExit", listener: BeforeExitListener): this;
  2018. prependListener(event: "disconnect", listener: DisconnectListener): this;
  2019. prependListener(event: "exit", listener: ExitListener): this;
  2020. prependListener(event: "rejectionHandled", listener: RejectionHandledListener): this;
  2021. prependListener(event: "uncaughtException", listener: UncaughtExceptionListener): this;
  2022. prependListener(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
  2023. prependListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
  2024. prependListener(event: "warning", listener: WarningListener): this;
  2025. prependListener(event: "message", listener: MessageListener): this;
  2026. prependListener(event: Signals, listener: SignalsListener): this;
  2027. prependListener(event: "multipleResolves", listener: MultipleResolveListener): this;
  2028. prependListener(event: "worker", listener: WorkerListener): this;
  2029. prependOnceListener(event: "beforeExit", listener: BeforeExitListener): this;
  2030. prependOnceListener(event: "disconnect", listener: DisconnectListener): this;
  2031. prependOnceListener(event: "exit", listener: ExitListener): this;
  2032. prependOnceListener(event: "rejectionHandled", listener: RejectionHandledListener): this;
  2033. prependOnceListener(event: "uncaughtException", listener: UncaughtExceptionListener): this;
  2034. prependOnceListener(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
  2035. prependOnceListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
  2036. prependOnceListener(event: "warning", listener: WarningListener): this;
  2037. prependOnceListener(event: "message", listener: MessageListener): this;
  2038. prependOnceListener(event: Signals, listener: SignalsListener): this;
  2039. prependOnceListener(event: "multipleResolves", listener: MultipleResolveListener): this;
  2040. prependOnceListener(event: "worker", listener: WorkerListener): this;
  2041. listeners(event: "beforeExit"): BeforeExitListener[];
  2042. listeners(event: "disconnect"): DisconnectListener[];
  2043. listeners(event: "exit"): ExitListener[];
  2044. listeners(event: "rejectionHandled"): RejectionHandledListener[];
  2045. listeners(event: "uncaughtException"): UncaughtExceptionListener[];
  2046. listeners(event: "uncaughtExceptionMonitor"): UncaughtExceptionListener[];
  2047. listeners(event: "unhandledRejection"): UnhandledRejectionListener[];
  2048. listeners(event: "warning"): WarningListener[];
  2049. listeners(event: "message"): MessageListener[];
  2050. listeners(event: Signals): SignalsListener[];
  2051. listeners(event: "multipleResolves"): MultipleResolveListener[];
  2052. listeners(event: "worker"): WorkerListener[];
  2053. }
  2054. }
  2055. }
  2056. export = process;
  2057. }
  2058. declare module "node:process" {
  2059. import process = require("process");
  2060. export = process;
  2061. }