The process.throwDeprecation property is an inbuilt application programming interface of the process module which is used to indicates whether the --throw-deprecation flag is set on the current Node.js process. process.throwDeprecation is mutable, so whether or not deprecation warnings result in errors may be altered at runtime.
Syntax:
process.throwDeprecation
Return Value: This property indicates whether the --throw-deprecation flag is set on the current Node.js process.
Below examples illustrate the use of process.throwDeprecation property in Node.js:
Example 1:
// Node.js program to demonstrate the
// process.throwDeprecation Property
// Include process module
const process = require('process');
// Printing process.throwDeprecation
// property value
console.log(process.throwDeprecation);
Command to run: node --throw-deprecation hello.js
Output 1:
true
Command to run: node hello.js
Output 2:
undefined
Example 2:
// Node.js program to demonstrate the
// process.throwDeprecation Property
// Include process module
const process = require('process');
// Instance Properties
process.throwDeprecation = false;
// Printing process.throwDeprecation
// property value
console.log(process.throwDeprecation);
// Instance Properties
process.throwDeprecation = true;
// Printing process.throwDeprecation
// property value
console.log(process.throwDeprecation);
Command to run: node --throw-deprecation hello.js
Output 1:
true true
Command to run: node hello.js
Output 2:
false true
Reference: https://nodejs.org/api/process.html#process_process_throwdeprecation