- 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 使用 Where 條件
- Node.js - MySQL 使用 Order By 排序
- 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.release() 方法
Node.js os.release() 方法返回一個字串值,該值指定作業系統版本。對於 UNIX 和 LINUX 系統,該函式使用名為 uname 的命令識別作業系統。在 Windows 上,使用 Win32 API 中名為 GetVersionExW() 的函式。
語法
以下是 Node.js os.release() 方法的語法:
os.release()
引數
此方法不接受任何引數。
返回值
此方法返回一個字串,指示作業系統的版本。
示例
在以下示例中,我們嘗試在Windows 作業系統中執行Node.js os.release() 方法。
const os = require('os');
console.log('On windows');
console.log(os.release());
輸出
3.10.0-1160.76.1.el7.x86_64
注意 - 要獲得準確的結果,最好在本地執行上述程式碼。
如果我們編譯並執行上述程式,則os.release() 方法將列印當前作業系統的版本。
10.0.22621
示例
在以下示例中,我們嘗試在 LINUX 作業系統中執行os.release() 方法。
const os = require('os');
console.log('On LINUX');
console.log(os.release());
輸出
在執行上述程式後,os.release() 方法將返回當前作業系統的版本。
5.16.0-kali7-amd64
示例
在本例中,我們列印當前作業系統的平臺和版本。
const os = require('os');
var platform = os.platform();
var release = os.release();
if(platform === 'win32'){
console.log("The platform: " + platform);
console.log("The version: " + release);
}
輸出
注意 - 要獲得準確的結果,最好在本地執行上述程式碼。
執行上述程式後,os.platform() 方法列印作業系統平臺,os.release() 方法列印作業系統版本。
The platform: win32 The version: 10.0.22621
nodejs_os_module.htm
廣告
