简体   繁体   中英

Create a New Directory Folder in NodeJS

const fs = require('fs');

 const path = require('path');

   fs.mkdir(path.join(__dirname, '/Foldername'), {}, err => {
      if(err) throw err;
console.log('Your Folder Has Been Created SuccessFully');

});

create a variable called '__dirname' and assign the path to it. Don't forget you escape characters. Something like:

const __dirname = "C:\\git"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM