get system name in typescript

To get the operating system name in TypeScript, you can use the following code snippet in Node.js:

index.ts
import { hostname } from 'os';

const systemName = hostname();
console.log(systemName); // Output: your system name
116 chars
5 lines

The hostname() method from Node.js built-in os module returns the operating system hostname. This method returns a string that represents the hostname of the operating system the Node.js process is running on.

gistlibby LogSnag