--disable-warning=code-or-type
¥Stability: 1.1 - Active development
按 code
或 type
禁用特定进程警告。
¥Disable specific process warnings by code
or type
.
从 process.emitWarning()
触发的警告可能包含 code
和 type
。此选项不会触发具有匹配 code
或 type
的警告。
¥Warnings emitted from process.emitWarning()
may contain a
code
and a type
. This option will not-emit warnings that have a matching
code
or type
.
弃用警告 名单。
¥List of deprecation warnings.
Node.js 核心警告类型有:DeprecationWarning
和 ExperimentalWarning
¥The Node.js core warning types are: DeprecationWarning
and
ExperimentalWarning
例如,以下脚本在使用 node --disable-warning=DEP0025
执行时不会触发 DEP0025 require('node:sys')
:
¥For example, the following script will not emit
DEP0025 require('node:sys')
when executed with
node --disable-warning=DEP0025
:
import sys from 'node:sys';
const sys = require('node:sys');
例如,当使用 node --disable-warning=ExperimentalWarning
执行时,以下脚本将触发 DEP0025 require('node:sys')
,但不会触发任何实验警告(例如 <=v21 中的 实验警告:vm.measureMemory
是一个实验性功能):
¥For example, the following script will emit the
DEP0025 require('node:sys')
, but not any Experimental
Warnings (such as
ExperimentalWarning: vm.measureMemory
is an experimental feature
in <=v21) when executed with node --disable-warning=ExperimentalWarning
:
import sys from 'node:sys';
import vm from 'node:vm';
vm.measureMemory();
const sys = require('node:sys');
const vm = require('node:vm');
vm.measureMemory();