2cd905c463ca8fad4ccda3af0f81e84132727543fe7aeea36f981d7b62248ab56072453ce03b3ec8421551d9a2df0d5b161e7e976ee160550abc42452fca59 104 KB

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