1. get-os-info
This library allows you to get a correct OS name and version
get-os-info
Package: get-os-info
Created by: Artem-Babich
Last modified: Thu, 19 May 2022 18:22:23 GMT
Version: 1.0.2
License: ISC
Downloads: 706,701
Repository: https://github.com/Artem-Babich/get-os-info

Install

npm install get-os-info
yarn add get-os-info

get-os-info

Get the name and version of the local OS

This package is based on the macos-release
, windows-release and getos
packages.

Install

$ npm install get-os-info

Usage

TypeScript

 import getOSInfo, { OSInfo } from 'get-os-info'

const info: OSInfo | null = await getOSInfo();

if (info)
    console.log(info.name, info.version)

// Example:
// {
//   name: 'Windows',
//   version: '11'
// }

JavaScript

 import { getOSInfo } from 'get-os-info';
//or
const { getOSInfo } = require('get-os-info');

const info = await getOSInfo();

Separate functions

 import os from 'os'
import { getMacInfo, getWindowsInfo, getLinuxInfo } from "get-os-info";
//or
const os = require("os");
const { getMacInfo, getWindowsInfo, getLinuxInfo } = require('get-os-info')

const release = os.release(); //'10.0.22000'

getWindowsInfo(release).then(info => {
    if (info)
        console.log(info);
})
// {
//   name:    'Windows',
//   version: '11'
// }

console.log(await getWindowsInfo()) // Will be the same

NOTE: Currently it is not possible to pass a release version argument to the getLinuxInfo function.


RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code