Skip to content
Tutorials Center
My learning

Topics

Node.js Reference ยท CLI Flags

Node.js --disable-warning flag

Reference for node --disable-warning: silence one warning by code (DEP0005) or type (ExperimentalWarning) instead of hiding every warning in the process.

--disable-warning=<code-or-type> tells Node.js not to print warnings that match a code (such as DEP0040) or a type (such as ExperimentalWarning). Everything else is still reported. That makes it a precise replacement for the blunt --no-warnings flag, which hides all warnings, including useful ones.

The flag can be repeated. It only affects the default stderr output: process.on('warning') listeners still receive every warning.

NODE
// shell: node --disable-warning=ExperimentalWarning app.js

Try it

Node.js Silencing by type and by code

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Node.js Listeners still see everything

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Syntax

NODE
// shell
node --disable-warning=<code-or-type> <script>
NODE_OPTIONS="--disable-warning=ExperimentalWarning" node <script>
Name Description
<code-or-type> The code property of a warning (for example DEP0005, MODULE_TYPELESS_PACKAGE_JSON) or its name/type (for example ExperimentalWarning, DeprecationWarning).

Returns: nothing. Matching warnings are not written to stderr.

Edge cases: a code or type that never occurs is accepted without complaint, so a typo silently does nothing.

Usage notes

  • Prefer the narrowest match. A code such as DEP0040 hides exactly one known warning; the type DeprecationWarning hides every present and future deprecation.
  • Find the code first. Warnings print as (node:1234) [DEP0040] DeprecationWarning: ...; the bracketed part is the code. Use --trace-warnings to see where it was raised.
  • Silencing is not fixing. Disable a warning only when you understand it and cannot change the cause, for example a noisy dependency or the ExperimentalWarning of a feature you knowingly use.
  • Programmatic equivalents: process.on('warning', ...) sees every warning, and process.noDeprecation = true hides deprecations from inside the program.
  • --no-warnings and NODE_NO_WARNINGS=1 hide everything. Reach for them only in throwaway scripts.
  • NODE_OPTIONS accepts --disable-warning, which is the usual way to apply it to tools that start Node for you.
  • Not a security setting. The flag changes output only, never behavior. A deprecated API still behaves as before.
  • Version notes: added in Node.js 21.3 and 20.11.