Node.js – process.throwDeprecation() 方法
此方法指示 **--throw-deprecation** 标志值在当前 Node.js 项目中设置为 true 或 false。
process.throwDeprecation() 方法是可变的,因此弃用警告导致的错误可能会在运行时被更改。
语法
process.throwDeprecation( )
示例1
创建一个名为"throwDeprecation.js"的文件,并复制以下代码。创建文件后,使用"node throwDeprecation.js"命令运行此代码,如下例所示
// process.throwDeprecation() Demo Example
// Importing the process module
const process = require('process');
// Printing the --throw-Deprecation default value
console.log(process.throwDeprecation);输出 1
undefined
输出 2
true
示例 2
我们来看另一个示例
// process.throwDeprecation() Demo Example
// Importing the process module
const process = require('process');
// Initializing the throwDeprecation flag
process.throwDeprecation = false;
// Printing throwDeprecation
console.log(process.throwDeprecation);
// Initializing the throwDeprecation flag
process.throwDeprecation = true;
// Printing throwDeprecation
console.log(process.throwDeprecation);输出 1
false true
输出 2
true true
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP