Node.js process.throwDeprecation Property
Last Updated :
11 Jun, 2021
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:
Javascript
const process = require( 'process' );
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:
Javascript
const process = require( 'process' );
process.throwDeprecation = false ;
console.log(process.throwDeprecation);
process.throwDeprecation = true ;
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
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...