The fs.mkdtempSync() method is an inbuilt application programming interface of fs module which provides an API for interacting with the file system in a manner closely modeled around standard POSIX functions. The fs.mkdtempSync() method creates a unique temporary directory. This is the synchronous version of fs.mkdtemp() method.
fs.mkdtempSync( prefix, options )
Parameters: This method accept two parameters as mentioned above and described below:
- Prefix: The six random characters are appended behind the prefix to create a unique temporary directory.
- Options: It is an optional parameter that can be a string specifying an encoding, or an object with an encoding property specifying the character encoding to use.
Return value: It returns the created folder path.
Below examples illustrate the use of fs.mkdtempSync() method in Node.js: