- Node.js 教程
- Node.js - 首頁
- Node.js - 簡介
- Node.js - 環境搭建
- Node.js - 第一個應用程式
- Node.js - REPL 終端
- Node.js - 命令列選項
- Node.js - 包管理器 (NPM)
- Node.js - 回撥函式概念
- Node.js - 上傳檔案
- Node.js - 傳送電子郵件
- Node.js - 事件
- Node.js - 事件迴圈
- Node.js - 事件發射器
- Node.js - 偵錯程式
- Node.js - 全域性物件
- Node.js - 控制檯
- Node.js - 程序
- Node.js - 應用程式擴充套件
- Node.js - 打包
- Node.js - Express 框架
- Node.js - RESTFul API
- Node.js - 緩衝區
- Node.js - 流
- Node.js - 檔案系統
- Node.js MySQL
- Node.js - MySQL 入門
- Node.js - MySQL 建立資料庫
- Node.js - MySQL 建立表
- Node.js - MySQL 插入資料
- Node.js - MySQL 從表中選擇資料
- Node.js - MySQL 條件查詢
- Node.js - MySQL 排序
- Node.js - MySQL 刪除資料
- Node.js - MySQL 更新資料
- Node.js - MySQL 連線查詢
- Node.js MongoDB
- Node.js - MongoDB 入門
- Node.js - MongoDB 建立資料庫
- Node.js - MongoDB 建立集合
- Node.js - MongoDB 插入資料
- Node.js - MongoDB 查詢資料
- Node.js - MongoDB 查詢
- Node.js - MongoDB 排序
- Node.js - MongoDB 刪除資料
- Node.js - MongoDB 更新資料
- Node.js - MongoDB 限制結果
- Node.js - MongoDB 連線查詢
- Node.js 模組
- Node.js - 模組
- Node.js - 內建模組
- Node.js - 實用工具模組
- Node.js - Web 模組
- Node.js 有用資源
- Node.js - 快速指南
- Node.js - 有用資源
- Node.js - 討論
Node.js - os.devNull 屬性
Node.js 的 os 模組提供了一系列與作業系統相關的實用方法和屬性。
Node.js 的 os.devNull 屬性將返回裝置的特定於平臺的檔案路徑。os.devNull 的可能輸出在 Windows 作業系統上為 \\.\nul,在 POSIX 作業系統上為 /dev/null。
可以透過標準庫 fs 模組訪問它,並且對於寫入不需要或不需要的資料很有用。例如,如果您正在除錯應用程式並希望快速測試某些內容而無需實際列印任何內容,則可以使用 devNull 屬性,而不是將除錯資訊寫入其他位置。
語法
以下是 Node.js os.devNull 屬性的語法:
os.devNull
返回值
此方法將返回空裝置的特定於平臺的檔案路徑。
以下是一個演示 os.devNull 在 Node.js 中用法的示例。
示例
在下面的示例中,我們嘗試將 os.devNull 屬性記錄到控制檯。
const os = require('os');
console.log(os.devNull);
輸出
undefined
注意 - 要檢視實際結果,請在本地執行以上程式碼。
如果我們編譯並執行以上程式碼,os.devNull 將返回一個字串值,如下所示。
\\.\nul
nodejs_os_module.htm
廣告
