@@ -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
@@ -766,8 +749,6 @@ process.addUncaughtExceptionCaptureCallback((err) => {
766749```
767750
768751``` cjs
769- const process = require (' node:process' );
770-
771752process .addUncaughtExceptionCaptureCallback ((err ) => {
772753 console .error (' Caught exception:' , err .message );
773754 return true ; // Indicates exception was handled
@@ -1217,8 +1198,6 @@ process.debugPort = 5858;
12171198```
12181199
12191200``` cjs
1220- const process = require (' node:process' );
1221-
12221201process .debugPort = 5858 ;
12231202```
12241203
@@ -1355,8 +1334,6 @@ process.on('warning', (warning) => {
13551334` ` `
13561335
13571336` ` ` cjs
1358- const process = require (' node:process' );
1359-
13601337process .on (' warning' , (warning ) => {
13611338 console .warn (warning .name ); // 'Warning'
13621339 console .warn (warning .message ); // 'Something happened!'
@@ -1448,8 +1425,6 @@ process.on('warning', (warning) => {
14481425` ` `
14491426
14501427` ` ` cjs
1451- const process = require (' node:process' );
1452-
14531428process .on (' warning' , (warning ) => {
14541429 console .warn (warning .name );
14551430 console .warn (warning .message );
@@ -1865,8 +1840,6 @@ if (someConditionNotMet()) {
18651840` ` `
18661841
18671842` ` ` cjs
1868- const process = require (' node:process' );
1869-
18701843// How to properly set the exit code while letting
18711844// the process exit gracefully.
18721845if (someConditionNotMet ()) {
@@ -2408,8 +2381,6 @@ if (process.getegid) {
24082381` ` `
24092382
24102383` ` ` cjs
2411- const process = require (' node:process' );
2412-
24132384if (process .getegid ) {
24142385 console .log (` Current gid: ${ process .getegid ()} ` );
24152386}
@@ -2438,8 +2409,6 @@ if (process.geteuid) {
24382409` ` `
24392410
24402411` ` ` cjs
2441- const process = require (' node:process' );
2442-
24432412if (process .geteuid ) {
24442413 console .log (` Current uid: ${ process .geteuid ()} ` );
24452414}
@@ -2468,8 +2437,6 @@ if (process.getgid) {
24682437` ` `
24692438
24702439` ` ` cjs
2471- const process = require (' node:process' );
2472-
24732440if (process .getgid ) {
24742441 console .log (` Current gid: ${ process .getgid ()} ` );
24752442}
@@ -2499,8 +2466,6 @@ if (process.getgroups) {
24992466` ` `
25002467
25012468` ` ` cjs
2502- const process = require (' node:process' );
2503-
25042469if (process .getgroups ) {
25052470 console .log (process .getgroups ()); // [ 16, 21, 297 ]
25062471}
@@ -2529,8 +2494,6 @@ if (process.getuid) {
25292494` ` `
25302495
25312496` ` ` cjs
2532- const process = require (' node:process' );
2533-
25342497if (process .getuid ) {
25352498 console .log (` Current uid: ${ process .getuid ()} ` );
25362499}
@@ -2735,8 +2698,6 @@ kill(process.pid, 'SIGHUP');
27352698` ` `
27362699
27372700` ` ` cjs
2738- const process = require (' node:process' );
2739-
27402701process .on (' SIGHUP' , () => {
27412702 console .log (' Got SIGHUP signal.' );
27422703});
@@ -3852,8 +3813,6 @@ if (process.getegid && process.setegid) {
38523813` ` `
38533814
38543815` ` ` cjs
3855- const process = require (' node:process' );
3856-
38573816if (process .getegid && process .setegid ) {
38583817 console .log (` Current gid: ${ process .getegid ()} ` );
38593818 try {
@@ -3897,8 +3856,6 @@ if (process.geteuid && process.seteuid) {
38973856` ` `
38983857
38993858` ` ` cjs
3900- const process = require (' node:process' );
3901-
39023859if (process .geteuid && process .seteuid ) {
39033860 console .log (` Current uid: ${ process .geteuid ()} ` );
39043861 try {
@@ -3942,8 +3899,6 @@ if (process.getgid && process.setgid) {
39423899` ` `
39433900
39443901` ` ` cjs
3945- const process = require (' node:process' );
3946-
39473902if (process .getgid && process .setgid ) {
39483903 console .log (` Current gid: ${ process .getgid ()} ` );
39493904 try {
@@ -3987,8 +3942,6 @@ if (process.getgroups && process.setgroups) {
39873942` ` `
39883943
39893944` ` ` cjs
3990- const process = require (' node:process' );
3991-
39923945if (process .getgroups && process .setgroups ) {
39933946 try {
39943947 process .setgroups ([501 ]);
@@ -4031,8 +3984,6 @@ if (process.getuid && process.setuid) {
40313984` ` `
40323985
40333986` ` ` cjs
4034- const process = require (' node:process' );
4035-
40363987if (process .getuid && process .setuid ) {
40373988 console .log (` Current uid: ${ process .getuid ()} ` );
40383989 try {
0 commit comments