Node.js – process.noDeprecation() 方法


process.noDeprecation() 方法指出 --no- Deprecation 標誌是否在當前 Node.js 專案中設定。此布林標誌控制是否將棄用警告訊息列印到 stderr。將此標誌設定為 True 會忽略所有棄用警告。

語法

process.noDeprecation( )

示例 1

建立一個名為 "noDeprecation.js" 的檔案,並複製下列程式碼。建立檔案後,使用命令 "node noDeprecation.js" 來執行此程式碼,如下例所示

// process.noDeprecation() Demo Example

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

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

輸出 1

undefined

輸出 2

true

示例 2

我們再舉一個例子 −

// 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);

輸出 1

false
true

輸出 2

true
true

更新於:2021 年 11 月 24 日

110 次瀏覽

開啟您的 職業生涯

完成課程,取得認證

立即開始
廣告
© . All rights reserved.