Node.js Create Directory
The mkdirSync() method is used
to create a new directory (folder) in Node.js.
Example
const fs = require("fs");
fs.mkdirSync("MyFolder");
console.log("Directory created successfully.");
Output:
Directory created successfully.
Explanation
- Import the fs module.
- Use mkdirSync().
- Give the name of the new folder.
- Node.js creates the folder.
↠Back to Home