process.debugPort屬性是進程模塊的內置應用程序編程接口,用於啟用調試器使用的調試端口。
用法:
process.debugPort
返回值:此屬性返回一個整數值,該值指定調試器(如果啟用)所使用的調試端口。
以下示例說明了Node.js中process.debugPort屬性的用法:
範例1:
// Node.js program to demonstrate the
// process.debugPort property
// Include process module
const process = require('process');
// Printing process.debugPort
console.log("debug port is " + process.debugPort);
輸出:
debug port is 9229
範例2:
// Node.js program to demonstrate the
// process.debugPort property
// Include process module
const process = require('process');
// Printing process.debugPort property value
var debug_port = process.debugPort;
// Check whether debug port is defined
if(debug_port != undefined){
console.log("debug port is defined");
console.log("debug port is " + debug_port);
}else{
console.log("debug port is not defined");
}
輸出:
debug port is defined debug port is 9229
注意:上麵的程序將通過使用node filename.js
命令。
參考: https://nodejs.org/api/process.html#process_process_debugport
相關用法
注:本文由純淨天空篩選整理自anwesha0107大神的英文原創作品 Node.js | process.debugPort Property。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。