Answers for "node js delete folder"

0

delete dir nodejs

fs.rmdirSync(dir, { recursive: true });
Posted by: Guest on August-06-2020
2

node js delete folder with files

const fs = require('fs');

// directory path
const dir = 'temp';

// delete directory recursively
try {
    fs.rmdirSync(dir, { recursive: true });

    console.log(`${dir} is deleted!`);
} catch (err) {
    console.error(`Error while deleting ${dir}.`);
}
Posted by: Guest on July-23-2021
1

nodejs fs delete non empty directory

var rimraf = require("rimraf");
rimraf("/some/directory", function () { console.log("done"); });
Posted by: Guest on November-24-2020
0

how to delete a folder using node js

fs.unlink('./node/myText.txt',function(){
    fs.rmdir('node');
});
Posted by: Guest on February-12-2021
0

how to delete everything from a folder in js

const fsPromises = require('fs').promises 
// For ES syntax: import { promises as fsPromises } from 'fs'

const directory = 'your/directory/path/here'

await fsPromises.rmdir(directory, {
  recursive: true
})
Posted by: Guest on August-11-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language