Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

delete dir nodejs

fs.rmdirSync(dir, { recursive: true });
Comment

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}.`);
}
Comment

fs node delete folder

const fs = require('fs');

fs.rmSync(folderPath, { recursive: true })
Comment

how to delete a folder in node js

//DeprecationWarning: In future versions of Node.js, fs.rmdir(path, { recursive: true }) will be removed. 
//Use fs.rm(path, { recursive: true }) instead
fs.rm(path, { recursive: true })
Comment

how to delete a folder using node js

fs.unlink('./node/myText.txt',function(){
    fs.rmdir('node');
});
Comment

node delete file folder

const fs = require('fs');
    const Path = require('path');

    const deleteFolderRecursive = function (directoryPath) {
    if (fs.existsSync(directoryPath)) {
        fs.readdirSync(directoryPath).forEach((file, index) => {
          const curPath = path.join(directoryPath, file);
          if (fs.lstatSync(curPath).isDirectory()) {
           // recurse
            deleteFolderRecursive(curPath);
          } else {
            // delete file
            fs.unlinkSync(curPath);
          }
        });
        fs.rmdirSync(directoryPath);
      }
    };
Comment

PREVIOUS NEXT
Code Example
Javascript :: map with promise.all 
Javascript :: how to map through array of iterators 
Javascript :: ajax get with parameters 
Javascript :: back button js 
Javascript :: how to check if a message has an attachment discord js 
Javascript :: get javascript min date 
Javascript :: get all div elements javascript 
Javascript :: web worker stop 
Javascript :: chart js two y axis 
Javascript :: encodeurl in javascript 
Javascript :: javascript setattribute 
Javascript :: js check if objects have same values 
Javascript :: code for adding new elements in javascriipt js 
Javascript :: jqurey cdn 
Javascript :: padend method in javascript 
Javascript :: regular expression match text between quotes 
Javascript :: react chart chart title 
Javascript :: add leading zeros javascript 
Javascript :: generate random color javascript 
Javascript :: how to use more than one transform in javascript 
Javascript :: set image as background react 
Javascript :: add variables in javascript 
Javascript :: jquery datatable iterate all rows 
Javascript :: get current date + 1 js 
Javascript :: javascript set checkbox checked based on value 
Javascript :: spring rest api cors error in react app 
Javascript :: How do I push an element into the array within an object in AngularJS 
Javascript :: convert object to boolean javascript 
Javascript :: generate random hex 
Javascript :: javascript on image load 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =