What is os-name?
The os-name npm package is a simple utility that allows you to get the name of the operating system in a human-readable format. It is useful for logging, debugging, and displaying system information in a user-friendly way.
What are os-name's main functionalities?
Get OS Name
This feature allows you to get the name of the operating system. The code sample demonstrates how to use the os-name package to print the OS name to the console.
const osName = require('os-name');
console.log(osName());
Get OS Name with Version
This feature allows you to get the name of the operating system along with its version. The code sample shows how to use the os-name package to print the OS name and version to the console.
const osName = require('os-name');
console.log(osName(os.platform(), os.release()));
Other packages similar to os-name
os
The 'os' module is a built-in Node.js module that provides operating system-related utility methods and properties. Unlike os-name, it does not provide a human-readable OS name but offers more detailed system information such as CPU architecture, network interfaces, and more.
systeminformation
The 'systeminformation' package is a comprehensive library for retrieving detailed system and hardware information. It provides much more detailed information compared to os-name, including CPU, memory, disk, and network details. However, it is more complex to use and may be overkill if you only need the OS name.
node-os-utils
The 'node-os-utils' package provides a set of utilities to get various system information such as CPU usage, memory usage, and more. It offers more functionality than os-name but does not focus specifically on providing a human-readable OS name.
os-name
Get the name of the current operating system
Example: macOS Sierra
Useful for analytics and debugging.
Install
$ npm install --save os-name
Usage
const os = require('os');
const osName = require('os-name');
osName();
osName(os.platform(), os.release());
osName('darwin', '14.0.0');
osName('linux', '3.13.0-24-generic');
osName('win32', '6.3.9600');
API
osName([platform, release])
By default the name of the current operating system is returned.
You can optionally supply a custom os.platform()
and os.release()
.
Check out getos if you need the Linux distribution name.
Contributing
Production systems depend on this package for logging / tracking. Please be careful when introducing new output, and adhere to existing output format (whitespace, capitalization, etc.).
Related
License
MIT © Sindre Sorhus