diff --git a/doc/api/cli.md b/doc/api/cli.md index 6b1860ecc81980..74e92637776fbc 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -443,6 +443,57 @@ Affects the default output directory of: * [`--heap-prof-dir`][] * [`--redirect-warnings`][] +### `--disable-warning=code-or-type` + +> Stability: 1.1 - Active development + + + +Disable specific process warnings by `code` or `type`. + +Warnings emitted from [`process.emitWarning()`][emit_warning] may contain a +`code` and a `type`. This option will not-emit warnings that have a matching +`code` or `type`. + +List of [deprecation warnings][]. + +The Node.js core warning types are: `DeprecationWarning` and +`ExperimentalWarning` + +For example, the following script will not emit +[DEP0025 `require('node:sys')`][DEP0025 warning] when executed with +`node --disable-warning=DEP0025`: + +```mjs +import sys from 'node:sys'; +``` + +```cjs +const sys = require('node:sys'); +``` + +For example, the following script will emit the +[DEP0025 `require('node:sys')`][DEP0025 warning], but not any Experimental +Warnings (such as +[ExperimentalWarning: `vm.measureMemory` is an experimental feature][] +in <=v21) when executed with `node --disable-warning=ExperimentalWarnings`: + +```mjs +import sys from 'node:sys'; +import vm from 'node:vm'; + +vm.measureMemory(); +``` + +```cjs +const sys = require('node:sys'); +const vm = require('node:vm'); + +vm.measureMemory(); +``` + ### `--disable-proto=mode`