Answers for "node create directory and file"

8

node js create folder

var fs = require('fs');

const dir = './database/temp';
if (!fs.existsSync(dir)) {
	fs.mkdirSync(dir, {
		recursive: true
	});
}
Posted by: Guest on June-23-2020
0

create directory when writing to file in nodejs

fs.mkdir now accepts a { recursive: true } option like so:

// Creates /tmp/a/apple, regardless of whether `/tmp` and /tmp/a exist.
fs.mkdir('/tmp/a/apple', { recursive: true }, (err) => {
  if (err) throw err;
});
Posted by: Guest on May-13-2021
0

how to create a folder using fs in node js

//Include fs module
const fs = require('fs');

const dir = './dir'
fs.mkdir(dir);
Posted by: Guest on July-28-2020

Code answers related to "node create directory and file"

Code answers related to "Javascript"

Browse Popular Code Answers by Language