Lines Matching +full:no +full:- +full:console
3 <!-- introduced_in=v0.10.0 -->
4 <!-- type=global -->
6 <!-- source_link=lib/process.js -->
22 <!-- YAML
24 -->
27 no additional work to schedule. Normally, the Node.js process will exit when
28 there is no work scheduled, but a listener registered on the `'beforeExit'`
43 console.log('Process beforeExit event with code: ', code);
47 console.log('Process exit event with code: ', code);
50 console.log('This message is displayed first.');
59 <!-- YAML
61 -->
68 <!-- YAML
70 -->
78 * The Node.js event loop no longer having any additional work to perform.
80 There is no way to prevent the exiting of the event loop at this point, and once
89 console.log(`About to exit with code: ${code}`);
101 console.log('This will not run');
107 <!-- YAML
109 -->
130 <!-- YAML
132 -->
153 console.error(type, promise, reason);
169 main().then(console.log);
179 <!-- YAML
181 -->
193 There is no notion of a top level for a `Promise` chain at which rejections can
199 an ever-growing list of unhandled exceptions, with Promises there can be a
200 growing-and-shrinking list of unhandled rejections.
222 likely best for long-running application) or upon process exit (which is likely
226 <!-- YAML
229 - version:
230 - v12.0.0
231 - v10.17.0
232 pr-url: https://github.com/nodejs/node/pull/26599
234 -->
240 [`--unhandled-rejections`][] flag set to `strict` or `throw` and
263 console.log('This will still run.');
268 console.log('This will not run.');
285 process will exit with a non-zero exit code and the stack trace will be printed.
303 <!-- YAML
305 -->
311 [`--unhandled-rejections`][] flag set to `strict` or `throw` and
320 still crash if no `'uncaughtException'` listener is installed.
333 <!-- YAML
336 - version: v7.0.0
337 pr-url: https://github.com/nodejs/node/pull/8217
339 - version: v6.6.0
340 pr-url: https://github.com/nodejs/node/pull/8223
343 -->
350 no error handler is attached to the promise within a turn of the event loop.
359 console.log('Unhandled Rejection at:', promise, 'reason:', reason);
365 }); // No `.catch()` or `.then()`
378 // no .catch or .then on resource.loaded for at least a turn
383 address such failures, a non-operational
389 <!-- YAML
391 -->
395 * `message` {string} A system-provided description of the warning.
405 lead to sub-optimal application performance, bugs, or security vulnerabilities.
409 console.warn(warning.name); // Print the warning name
410 console.warn(warning.message); // Print the warning message
411 console.warn(warning.stack); // Print the stack trace
415 By default, Node.js will print process warnings to `stderr`. The `--no-warnings`
416 command-line option can be used to suppress the default console output but the
422 ```console
434 ```console
435 $ node --no-warnings
436 > const p = process.on('warning', (warning) => console.warn('Do not do that!'));
443 The `--trace-warnings` command-line option can be used to have the default
444 console output for warnings include the full stack trace of the warning.
446 Launching Node.js using the `--throw-deprecation` command-line flag will
449 Using the `--trace-deprecation` command-line flag will cause the custom
452 Using the `--no-deprecation` command-line flag will suppress all reporting
455 The `*-deprecation` command-line flags only affect warnings that use the name
459 <!-- YAML
461 -->
470 custom or application-specific warnings.
474 There are no strict guidelines for warning types (as identified by the `name`
478 * `'DeprecationWarning'` - Indicates use of a deprecated Node.js API or feature.
481 * `'ExperimentalWarning'` - Indicates use of an experimental Node.js API or
483 time and are not subject to the same strict semantic-versioning and long-term
485 * `'MaxListenersExceededWarning'` - Indicates that too many listeners for a
488 * `'TimeoutOverflowWarning'` - Indicates that a numeric value that cannot fit
489 within a 32-bit signed integer has been provided to either the `setTimeout()`
491 * `'UnsupportedWarning'` - Indicates use of an unsupported option or feature
497 <!--type=event-->
498 <!--name=SIGINT, SIGHUP, etc.-->
517 console.log('Received SIGINT. Press Control-D to exit.');
522 console.log(`Received ${signal}`);
531 * `'SIGTERM'` and `'SIGINT'` have default handlers on non-Windows platforms that
534 removed (Node.js will no longer exit).
536 * `'SIGHUP'` is generated on Windows when the console window is closed, and on
539 Windows about 10 seconds later. On non-Windows platforms, the default
548 pressed. On non-Windows platforms, it can be listened on, but there is no way
550 * `'SIGWINCH'` is delivered when the console has been resized. On Windows, this
551 will only happen on write to the console when the cursor is being moved, or
560 * `0` can be sent to test for the existence of a process, it has no effect if
563 Windows does not support signals so has no equivalent to termination by signal,
573 <!-- YAML
575 -->
583 <!-- YAML
585 -->
590 read-only `Set` of flags allowable within the [`NODE_OPTIONS`][]
598 * Flags may omit leading single (`-`) or double (`--`) dashes; e.g.,
599 `inspect-brk` for `--inspect-brk`, or `r` for `-r`.
600 * Flags passed through to V8 (as listed in `--v8-options`) may replace
601 one or more *non-leading* dashes for an underscore, or vice-versa;
602 e.g., `--perf_basic_prof`, `--perf-basic-prof`, `--perf_basic-prof`,
606 e.g., `--stack-trace-limit=100`.
611 passed through to V8 will contain underscores instead of non-leading
616 // -r
617 // --inspect-brk
618 // --abort_on_uncaught_exception
632 <!-- YAML
634 -->
643 console.log(`This processor architecture is ${process.arch}`);
647 <!-- YAML
649 -->
653 The `process.argv` property returns an array containing the command-line
657 file being executed. The remaining elements will be any additional command-line
660 For example, assuming the following script for `process-args.js`:
665 console.log(`${index}: ${val}`);
671 ```console
672 $ node process-args.js one two=three four
679 1: /Users/mjr/work/node/process-args.js
686 <!-- YAML
688 -->
692 The `process.argv0` property stores a read-only copy of the original value of
695 ```console
696 $ bash -c 'exec -a customArgv0 ./node'
704 <!-- YAML
707 - version: v14.0.0
708 pr-url: https://github.com/nodejs/node/pull/30165
709 description: The object no longer accidentally exposes native C++ bindings.
710 -->
716 property is a reference to the IPC channel. If no IPC channel exists, this
720 <!-- YAML
722 -->
732 <!-- YAML
734 -->
744 <!-- YAML
746 -->
755 console.log(`Starting directory: ${process.cwd()}`);
758 console.log(`New directory: ${process.cwd()}`);
760 console.error(`chdir: ${err}`);
767 <!-- YAML
769 -->
780 <!-- eslint-skip -->
809 The `process.config` property is **not** read-only and there are existing
814 <!-- YAML
816 -->
825 Once `process.connected` is `false`, it is no longer possible to send messages
829 <!-- YAML
831 -->
854 while (Date.now() - now < 500);
856 console.log(process.cpuUsage(startUsage));
861 <!-- YAML
863 -->
871 console.log(`Current directory: ${process.cwd()}`);
875 <!-- YAML
877 -->
888 <!-- YAML
890 -->
895 once there are no other connections keeping it alive.
904 <!-- YAML
907 - version: v9.0.0
908 pr-url: https://github.com/nodejs/node/pull/12794
910 -->
944 <!-- YAML
946 -->
979 console.warn(warning.name); // 'Warning'
980 console.warn(warning.message); // 'Something happened!'
981 console.warn(warning.code); // 'MY_WARNING'
982 console.warn(warning.stack); // Stack trace
983 console.warn(warning.detail); // 'This is some additional information'
990 <!-- YAML
992 -->
1029 console.warn(warning.name);
1030 console.warn(warning.message);
1031 console.warn(warning.code);
1032 console.warn(warning.stack);
1060 * If the `--throw-deprecation` command-line flag is used, the deprecation
1062 * If the `--no-deprecation` command-line flag is used, the deprecation
1064 * If the `--trace-deprecation` command-line flag is used, the deprecation
1087 <!-- YAML
1090 - version: v11.14.0
1091 pr-url: https://github.com/nodejs/node/pull/26544
1095 - version: v10.0.0
1096 pr-url: https://github.com/nodejs/node/pull/18990
1098 -->
1107 <!-- eslint-skip -->
1110 TERM: 'xterm-256color',
1128 ```console
1129 $ node -e 'process.env.foo = "bar"' && echo $foo
1136 console.log(process.env.foo);
1145 console.log(process.env.test);
1148 console.log(process.env.test);
1157 console.log(process.env.TEST);
1161 On Windows operating systems, environment variables are case-insensitive.
1165 console.log(process.env.test);
1174 are visible to the operating system or to native add-ons.
1177 <!-- YAML
1179 -->
1183 The `process.execArgv` property returns the set of Node.js-specific command-line
1190 ```console
1191 $ node --harmony script.js --version
1196 <!-- eslint-disable semi -->
1198 ['--harmony']
1203 <!-- eslint-disable semi -->
1205 ['/usr/local/bin/node', 'script.js', '--version']
1212 <!-- YAML
1214 -->
1221 <!-- eslint-disable semi -->
1227 <!-- YAML
1229 -->
1253 explicitly. The Node.js process will exit on its own *if there is no additional
1295 <!-- YAML
1297 -->
1309 <!-- YAML
1311 -->
1318 console.log(`Current gid: ${process.getegid()}`);
1326 <!-- YAML
1328 -->
1337 console.log(`Current uid: ${process.geteuid()}`);
1345 <!-- YAML
1347 -->
1356 console.log(`Current gid: ${process.getgid()}`);
1364 <!-- YAML
1366 -->
1376 console.log(process.getgroups()); // [ 16, 21, 297 ]
1384 <!-- YAML
1386 -->
1395 console.log(`Current uid: ${process.getuid()}`);
1403 <!-- YAML
1405 -->
1413 <!-- YAML
1415 -->
1417 > Stability: 3 - Legacy. Use [`process.hrtime.bigint()`][] instead.
1425 The `process.hrtime()` method returns the current high-resolution real time
1432 user-defined array instead of the result of a previous call to
1448 console.log(`Benchmark took ${diff[0] * NS_PER_SEC + diff[1]} nanoseconds`);
1454 <!-- YAML
1456 -->
1461 current high-resolution real time in nanoseconds as a `bigint`.
1475 console.log(`Benchmark took ${end - start} nanoseconds`);
1481 <!-- YAML
1483 -->
1496 console.log(process.getgroups()); // [ 0 ]
1498 console.log(process.getgroups()); // [ 27, 30, 46, 1000, 0 ]
1500 console.log(process.getgroups()); // [ 27, 30, 46, 1000 ]
1508 <!-- YAML
1510 -->
1533 console.log('Got SIGHUP signal.');
1537 console.log('Exiting.');
1548 <!-- YAML
1551 -->
1553 > Stability: 0 - Deprecated: Use [`require.main`][] instead.
1564 is no entry script.
1567 <!-- YAML
1570 - version: v13.9.0
1571 pr-url: https://github.com/nodejs/node/pull/31550
1573 - version: v7.2.0
1574 pr-url: https://github.com/nodejs/node/pull/9587
1576 -->
1589 console.log(process.memoryUsage());
1620 <!-- YAML
1622 -->
1637 console.log(process.memoryUsage.rss());
1642 <!-- YAML
1645 - version: v1.8.1
1646 pr-url: https://github.com/nodejs/node/pull/1077
1648 -->
1660 console.log('start');
1662 console.log('nextTick callback');
1664 console.log('scheduled');
1741 Promise.resolve().then(() => console.log(2));
1742 queueMicrotask(() => console.log(3));
1743 process.nextTick(() => console.log(1));
1753 In simple scenarios, `queueMicrotask()` can be a drop-in replacement for
1757 console.log('start');
1759 console.log('microtask callback');
1761 console.log('scheduled');
1768 One note-worthy difference between the two APIs is that `process.nextTick()`
1775 console.log('microtask', a + b);
1778 console.log('start');
1780 console.log('scheduled');
1797 <!-- YAML
1799 -->
1803 The `process.noDeprecation` property indicates whether the `--no-deprecation`
1810 <!-- YAML
1812 -->
1819 console.log(`This process is pid ${process.pid}`);
1823 <!-- YAML
1825 -->
1843 console.log(`This platform is ${process.platform}`);
1851 <!-- YAML
1853 - v9.2.0
1854 - v8.10.0
1855 - v6.13.0
1856 -->
1864 console.log(`The parent process is pid ${process.ppid}`);
1868 <!-- YAML
1871 - version: v4.2.0
1872 pr-url: https://github.com/nodejs/node/pull/3212
1874 -->
1879 to the current release, including URLs for the source tarball and headers-only
1890 Node.js native add-ons.
1893 compiling Node.js native add-ons. _This property is only present on Windows
1899 that are no longer supported).
1904 <!-- eslint-skip -->
1909 sourceUrl: 'https://nodejs.org/download/release/v12.18.1/node-v12.18.1.tar.gz',
1910 headersUrl: 'https://nodejs.org/download/release/v12.18.1/node-v12.18.1-headers.tar.gz',
1911 libUrl: 'https://nodejs.org/download/release/v12.18.1/win-x64/node.lib'
1915 In custom builds from non-release versions of the source tree, only the
1920 <!-- YAML
1923 - version: v13.12.0
1924 pr-url: https://github.com/nodejs/node/pull/32242
1925 description: This API is no longer experimental.
1926 -->
1935 <!-- YAML
1937 -->
1941 Write reports in a compact format, single-line JSON, more easily consumable
1942 by log processing systems than the default multi-line format designed for
1946 console.log(`Reports are compact? ${process.report.compact}`);
1950 <!-- YAML
1953 - version: v13.12.0
1954 pr-url: https://github.com/nodejs/node/pull/32242
1955 description: This API is no longer experimental.
1956 -->
1965 console.log(`Report directory is ${process.report.directory}`);
1969 <!-- YAML
1972 - version: v13.12.0
1973 pr-url: https://github.com/nodejs/node/pull/32242
1974 description: This API is no longer experimental.
1975 -->
1984 console.log(`Report filename is ${process.report.filename}`);
1988 <!-- YAML
1991 - version: v13.12.0
1992 pr-url: https://github.com/nodejs/node/pull/32242
1993 description: This API is no longer experimental.
1994 -->
2005 console.log(data.header.nodejsVersion);
2009 fs.writeFileSync('my-report.log', util.inspect(data), 'utf8');
2015 <!-- YAML
2018 - version:
2019 - v14.17.0
2020 pr-url: https://github.com/nodejs/node/pull/35654
2021 description: This API is no longer experimental.
2022 -->
2030 console.log(`Report on fatal error: ${process.report.reportOnFatalError}`);
2034 <!-- YAML
2037 - version: v13.12.0
2038 pr-url: https://github.com/nodejs/node/pull/32242
2039 description: This API is no longer experimental.
2040 -->
2048 console.log(`Report on signal: ${process.report.reportOnSignal}`);
2052 <!-- YAML
2055 - version: v13.12.0
2056 pr-url: https://github.com/nodejs/node/pull/32242
2057 description: This API is no longer experimental.
2058 -->
2065 console.log(`Report on exception: ${process.report.reportOnUncaughtException}`);
2069 <!-- YAML
2072 - version: v13.12.0
2073 pr-url: https://github.com/nodejs/node/pull/32242
2074 description: This API is no longer experimental.
2075 -->
2083 console.log(`Report signal: ${process.report.signal}`);
2087 <!-- YAML
2090 - version: v13.12.0
2091 pr-url: https://github.com/nodejs/node/pull/32242
2092 description: This API is no longer experimental.
2093 -->
2114 <!-- YAML
2116 -->
2162 console.log(process.resourceUsage());
2187 <!-- YAML
2189 -->
2212 <!-- YAML
2214 -->
2225 console.log(`Current gid: ${process.getegid()}`);
2228 console.log(`New gid: ${process.getegid()}`);
2230 console.log(`Failed to set gid: ${err}`);
2240 <!-- YAML
2242 -->
2253 console.log(`Current uid: ${process.geteuid()}`);
2256 console.log(`New uid: ${process.geteuid()}`);
2258 console.log(`Failed to set uid: ${err}`);
2268 <!-- YAML
2270 -->
2281 console.log(`Current gid: ${process.getgid()}`);
2284 console.log(`New gid: ${process.getgid()}`);
2286 console.log(`Failed to set gid: ${err}`);
2296 <!-- YAML
2298 -->
2312 console.log(process.getgroups()); // new groups
2314 console.log(`Failed to set groups: ${err}`);
2324 <!-- YAML
2326 -->
2337 console.log(`Current uid: ${process.getuid()}`);
2340 console.log(`New uid: ${process.getuid()}`);
2342 console.log(`Failed to set uid: ${err}`);
2352 <!-- YAML
2354 -->
2356 > Stability: 1 - Experimental
2364 `--enable-source-maps`.
2370 <!-- YAML
2372 -->
2381 not be emitted. If `--abort-on-uncaught-exception` was passed from the
2388 method with a non-`null` argument while another capture function is set will
2392 [`domain`][] built-in module.
2472 1. They are used internally by [`console.log()`][] and [`console.error()`][],
2483 Synchronous writes avoid problems such as output written with `console.log()` or
2484 `console.error()` being unexpectedly interleaved, or not written at all if
2502 ```console
2503 $ node -p "Boolean(process.stdin.isTTY)"
2505 $ echo "foo" | node -p "Boolean(process.stdin.isTTY)"
2507 $ node -p "Boolean(process.stdout.isTTY)"
2509 $ node -p "Boolean(process.stdout.isTTY)" | cat
2516 <!-- YAML
2518 -->
2523 `--throw-deprecation` flag is set on the current Node.js process.
2529 ```console
2530 $ node --throw-deprecation -p "process.throwDeprecation"
2532 $ node -p "process.throwDeprecation"
2546 <!-- YAML
2548 -->
2559 binary name plus the length of the command-line arguments because setting the
2570 <!-- YAML
2572 -->
2577 `--trace-deprecation` flag is set on the current Node.js process. See the
2583 <!-- YAML
2586 - version:
2587 - v14.0.0
2588 - v12.19.0
2589 pr-url: https://github.com/nodejs/node/pull/32499
2590 description: Calling `process.umask()` with no arguments is deprecated.
2592 -->
2594 > Stability: 0 - Deprecated. Calling `process.umask()` with no argument causes
2595 > the process-wide umask to be written twice. This introduces a race condition
2596 > between threads, and is a potential security vulnerability. There is no safe,
2597 > cross-platform alternative API.
2603 <!-- YAML
2605 -->
2615 console.log(
2623 <!-- YAML
2625 -->
2636 <!-- YAML
2638 -->
2645 console.log(`Version: ${process.version}`);
2653 <!-- YAML
2656 - version: v9.0.0
2657 pr-url: https://github.com/nodejs/node/pull/15785
2659 - version: v4.2.0
2660 pr-url: https://github.com/nodejs/node/pull/3102
2662 -->
2672 console.log(process.versions);
2677 ```console
2679 v8: '7.0.276.38-node.18',
2697 Node.js will normally exit with a `0` status code when no more async
2716 * `6` **Non-function Internal Exception Handler**: There was an
2718 function was somehow set to a non-function, and could not be called.
2719 * `7` **Internal Exception Handler Run-Time Failure**: There was an
2728 * `10` **Internal JavaScript Run-Time Failure**: The JavaScript
2732 * `12` **Invalid Debug Argument**: The `--inspect` and/or `--inspect-brk`
2734 * `13` **Unfinished Top-Level Await**: `await` was used outside of a function
2735 in the top-level code, but the passed `Promise` never resolved.
2739 exit codes are defined to be 7-bit integers, and signal exits set
2740 the high-order bit, and then contain the value of the signal code.
2745 …g]: https://github.com/nodejs/node/blob/HEAD/BUILDING.md#androidandroid-based-devices-eg-firefox-os
2749 [Event Loop]: https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/#process-nexttick
2760 [`--unhandled-rejections`]: cli.md#cli_unhandled_rejections_mode
2768 [`Promise.race()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Object…
2771 [`console.error()`]: console.md#console_console_error_data_args
2772 [`console.log()`]: console.md#console_console_log_data_args
2786 [`promise.catch()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objec…