The
os.tmpdir() method is an inbuilt application programming interface of the os module which is used to get path of default directory for temporary files of the operating system.
Syntax:
os.tmpdir()
Parameters: This method does not accept any parameters.
Return Value: This method returns a string specifies the path to the default directory for temporary files of the operating system.
Below examples illustrate the use of os.tmpdir() method in Node.js:
Example 1:
Output:
C:\Users\gekcho\AppData\Local\Temp
Example 2:
Output:
home directory:C:\Users\gekcho
temp directory:C:\Users\gekcho\AppData\Local\Temp
Note: The above program will compile and run by using the
node index.js command.
Reference: https://nodejs.org/api/os.html#os_os_tmpdir