Node.js – process.noDeprecation() Method


This process.noDeprecation() method states whether the --no- Deprecation flag is set or not on the current Node.js project. This Boolean flag controls whether the deprecation warning messages are printed to stderr or not. Setting this flag as True will silence all the deprecation warnings.

Syntax

process.noDeprecation( )

Example 1

Create a file with the name "noDeprecation.js" and copy the following code. After creating the file, use the command "node noDeprecation.js" to run this code as shown in the example below

// process.noDeprecation() Demo Example

// Importing the process module
const process = require('process');

// Printing noDeprecation default value
console.log(process.noDeprecation);

Output 1

undefined

Output 2

true

Example 2

Let's take another example −

// process.noDeprecation() Demo Example

// Importing the process module
const process = require('process');

// Initializing the noDeprecation flag
process.noDeprecation = false;

// Printing noDeprecation
console.log(process.noDeprecation);

// Initializing the noDeprecation flag
process.noDeprecation = true;

// Printing noDeprecation
console.log(process.noDeprecation);

Output 1

false
true

Output 2

true
true

Updated on: 24-Nov-2021

88 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements