homedir method of OS module of node.js


Overview

This method is used to get the home directory of the current user. This method returns String . Code snippet is given below :

Code


													
//Name of the file: homedir.js
var os = require('os');
var value =  os.homedir();
console.log("os.homedir() => " + value);		
													
												

Run

  • Now run the snippet using the following command :
    													
    >node homedir.js
    os.homedir() => C:\Users\acer