VOOZH about

URL: https://www.geeksforgeeks.org/node-js/node-js-os-type-method/

⇱ Node.js os.type() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Node.js os.type() Method

Last Updated : 12 Oct, 2021

The os.type() method is an inbuilt application programming interface of the os module which is used to get Operating system name. Syntax:

os.type()

Parameters: This method does not accept any parameters.
Return Value: This method returns a string that represents operating system name. The returned value can be one of these 'Darwin' for MacOS, 'Linux' for Linux and 'Windows_NT' for windows.
Below examples illustrate the use of os.type() method in Node.js: Example 1:

// Node.js program to demonstrate the 
// os.type() method 

// Allocating os module
constos=require('os');

// Printing os.type() value
console.log(os.type());

Output: 

Windows_NT
Example 2:

Output:

windows operating system
Note: The above program will compile and run by using the node index.js command. Reference: https://nodejs.org/api/os.html#os_os_type
Comment

Explore