VOOZH about

URL: https://www.geeksforgeeks.org/node-js/node-js-fspromises-mkdir-method/

⇱ Node.js fsPromises.mkdir() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Node.js fsPromises.mkdir() Method

Last Updated : 8 Oct, 2021
The fsPromises.mkdir() method is used to asynchronously create a directory then resolves the Promise with either no arguments, or the first directory path created if recursive is true. Syntax:
fsPromises.mkdir(path, options)
Parameters: This method accept two parameters as mentioned above and described below:
  1. path: This parameter is a String, Buffer or URL and holds the path of the directory has to be created.
  2. options: It is an Object or an Integer
    • recursive: This parameter holds the recursive boolean value. By default it is false.
    • mode: The mode option is used to set the directory permission, by default it is 0777. It is a String or an Integer
Return Value: It returns the Promise object which represents the eventual completion (or failure) of an asynchronous operation, and its resulting value. Below example illustrates the use of fsPromises.mkdir() method in Node.js.

Example:

Output:
Directory created successfully!
Comment

Explore