Node.js – process.throwDeprecation() 方法
该方法表示当前项目中--throw-deprecation设置为True或False的标志值Node.js。
该方法是可变的,因此可能会在运行时更改导致错误的弃用警告。process.throwDeprecation()
语法
process.throwDeprecation( )
示例1
创建一个名为“throwDeprecation.js”的文件并复制以下代码。创建文件后,使用命令“nodethrowDeprecation.js”运行此代码,如下例所示
//process.throwDeprecation()演示示例
//导入流程模块
const process = require('process');
//打印--throw-Deprecation默认值
console.log(process.throwDeprecation);输出1
undefined
输出2
true
示例2
让我们再举一个例子
//process.throwDeprecation()演示示例
//导入流程模块
const process = require('process');
//初始化throwDeprecation标志
process.throwDeprecation = false;
//打印抛出弃用
console.log(process.throwDeprecation);
//初始化throwDeprecation标志
process.throwDeprecation = true;
//打印抛出弃用
console.log(process.throwDeprecation);输出1
false true
输出2
true true
热门推荐
10 财运虎年祝福语简短语
11 单亲爸爸春节祝福语简短
12 狗狗上厕所训练
13 植物种植祝福语简短
14 翻译考试祝福语朋友简短
15 个人周年庆简短祝福语
16 狗狗怎么训练
17 分别祝福语简短搞笑英文
18 生日广州男生祝福语简短