@@ -13,6 +13,8 @@ Node.js process.
1313import process from ' node:process' ;
1414```
1515
16+ <!-- eslint-disable no-restricted-syntax -->
17+
1618``` cjs
1719const process = require (' node:process' );
1820```
@@ -62,8 +64,6 @@ console.log('This message is displayed first.');
6264```
6365
6466``` cjs
65- const process = require (' node:process' );
66-
6767process .on (' beforeExit' , (code ) => {
6868 console .log (' Process beforeExit event with code: ' , code);
6969});
@@ -120,8 +120,6 @@ process.on('exit', (code) => {
120120```
121121
122122``` cjs
123- const process = require (' node:process' );
124-
125123process .on (' exit' , (code ) => {
126124 console .log (` About to exit with code: ${ code} ` );
127125});
@@ -143,8 +141,6 @@ process.on('exit', (code) => {
143141```
144142
145143``` cjs
146- const process = require (' node:process' );
147-
148144process .on (' exit' , (code ) => {
149145 setTimeout (() => {
150146 console .log (' This will not run' );
@@ -221,8 +217,6 @@ process.on('rejectionHandled', (promise) => {
221217```
222218
223219``` cjs
224- const process = require (' node:process' );
225-
226220const unhandledRejections = new Map ();
227221process .on (' unhandledRejection' , (reason , promise ) => {
228222 unhandledRejections .set (promise, reason);
@@ -305,7 +299,6 @@ console.log('This will not run.');
305299```
306300
307301``` cjs
308- const process = require (' node:process' );
309302const fs = require (' node:fs' );
310303
311304process .on (' uncaughtException' , (err , origin ) => {
@@ -394,8 +387,6 @@ nonexistentFunc();
394387```
395388
396389``` cjs
397- const process = require (' node:process' );
398-
399390process .on (' uncaughtExceptionMonitor' , (err , origin ) => {
400391 MyMonitoringTool .logSync (err, origin);
401392});
@@ -445,8 +436,6 @@ somePromise.then((res) => {
445436```
446437
447438``` cjs
448- const process = require (' node:process' );
449-
450439process .on (' unhandledRejection' , (reason , promise ) => {
451440 console .log (' Unhandled Rejection at:' , promise, ' reason:' , reason);
452441 // Application specific logging, throwing an error, or other logic here
@@ -473,8 +462,6 @@ const resource = new SomeResource();
473462```
474463
475464``` cjs
476- const process = require (' node:process' );
477-
478465function SomeResource () {
479466 // Initially set the loaded status to a rejected promise
480467 this .loaded = Promise .reject (new Error (' Resource not yet loaded!' ));
@@ -526,8 +513,6 @@ process.on('warning', (warning) => {
526513```
527514
528515``` cjs
529- const process = require (' node:process' );
530-
531516process .on (' warning' , (warning ) => {
532517 console .warn (warning .name ); // Print the warning name
533518 console .warn (warning .message ); // Print the warning message
@@ -663,8 +648,6 @@ process.on('SIGTERM', handle);
663648```
664649
665650``` cjs
666- const process = require (' node:process' );
667-
668651// Begin reading from stdin so the process does not exit.
669652process .stdin .resume ();
670653
@@ -767,8 +750,6 @@ process.addUncaughtExceptionCaptureCallback((err) => {
767750```
768751
769752``` cjs
770- const process = require (' node:process' );
771-
772753process .addUncaughtExceptionCaptureCallback ((err ) => {
773754 console .error (' Caught exception:' , err .message );
774755 return true ; // Indicates exception was handled
@@ -1218,8 +1199,6 @@ process.debugPort = 5858;
12181199```
12191200
12201201``` cjs
1221- const process = require (' node:process' );
1222-
12231202process .debugPort = 5858 ;
12241203```
12251204
@@ -1356,8 +1335,6 @@ process.on('warning', (warning) => {
13561335` ` `
13571336
13581337` ` ` cjs
1359- const process = require (' node:process' );
1360-
13611338process .on (' warning' , (warning ) => {
13621339 console .warn (warning .name ); // 'Warning'
13631340 console .warn (warning .message ); // 'Something happened!'
@@ -1449,8 +1426,6 @@ process.on('warning', (warning) => {
14491426` ` `
14501427
14511428` ` ` cjs
1452- const process = require (' node:process' );
1453-
14541429process .on (' warning' , (warning ) => {
14551430 console .warn (warning .name );
14561431 console .warn (warning .message );
@@ -1866,8 +1841,6 @@ if (someConditionNotMet()) {
18661841` ` `
18671842
18681843` ` ` cjs
1869- const process = require (' node:process' );
1870-
18711844// How to properly set the exit code while letting
18721845// the process exit gracefully.
18731846if (someConditionNotMet ()) {
@@ -2409,8 +2382,6 @@ if (process.getegid) {
24092382` ` `
24102383
24112384` ` ` cjs
2412- const process = require (' node:process' );
2413-
24142385if (process .getegid ) {
24152386 console .log (` Current gid: ${ process .getegid ()} ` );
24162387}
@@ -2439,8 +2410,6 @@ if (process.geteuid) {
24392410` ` `
24402411
24412412` ` ` cjs
2442- const process = require (' node:process' );
2443-
24442413if (process .geteuid ) {
24452414 console .log (` Current uid: ${ process .geteuid ()} ` );
24462415}
@@ -2469,8 +2438,6 @@ if (process.getgid) {
24692438` ` `
24702439
24712440` ` ` cjs
2472- const process = require (' node:process' );
2473-
24742441if (process .getgid ) {
24752442 console .log (` Current gid: ${ process .getgid ()} ` );
24762443}
@@ -2500,8 +2467,6 @@ if (process.getgroups) {
25002467` ` `
25012468
25022469` ` ` cjs
2503- const process = require (' node:process' );
2504-
25052470if (process .getgroups ) {
25062471 console .log (process .getgroups ()); // [ 16, 21, 297 ]
25072472}
@@ -2530,8 +2495,6 @@ if (process.getuid) {
25302495` ` `
25312496
25322497` ` ` cjs
2533- const process = require (' node:process' );
2534-
25352498if (process .getuid ) {
25362499 console .log (` Current uid: ${ process .getuid ()} ` );
25372500}
@@ -2736,8 +2699,6 @@ kill(process.pid, 'SIGHUP');
27362699` ` `
27372700
27382701` ` ` cjs
2739- const process = require (' node:process' );
2740-
27412702process .on (' SIGHUP' , () => {
27422703 console .log (' Got SIGHUP signal.' );
27432704});
@@ -3853,8 +3814,6 @@ if (process.getegid && process.setegid) {
38533814` ` `
38543815
38553816` ` ` cjs
3856- const process = require (' node:process' );
3857-
38583817if (process .getegid && process .setegid ) {
38593818 console .log (` Current gid: ${ process .getegid ()} ` );
38603819 try {
@@ -3898,8 +3857,6 @@ if (process.geteuid && process.seteuid) {
38983857` ` `
38993858
39003859` ` ` cjs
3901- const process = require (' node:process' );
3902-
39033860if (process .geteuid && process .seteuid ) {
39043861 console .log (` Current uid: ${ process .geteuid ()} ` );
39053862 try {
@@ -3943,8 +3900,6 @@ if (process.getgid && process.setgid) {
39433900` ` `
39443901
39453902` ` ` cjs
3946- const process = require (' node:process' );
3947-
39483903if (process .getgid && process .setgid ) {
39493904 console .log (` Current gid: ${ process .getgid ()} ` );
39503905 try {
@@ -3988,8 +3943,6 @@ if (process.getgroups && process.setgroups) {
39883943` ` `
39893944
39903945` ` ` cjs
3991- const process = require (' node:process' );
3992-
39933946if (process .getgroups && process .setgroups ) {
39943947 try {
39953948 process .setgroups ([501 ]);
@@ -4032,8 +3985,6 @@ if (process.getuid && process.setuid) {
40323985` ` `
40333986
40343987` ` ` cjs
4035- const process = require (' node:process' );
4036-
40373988if (process .getuid && process .setuid ) {
40383989 console .log (` Current uid: ${ process .getuid ()} ` );
40393990 try {
0 commit comments