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 :: javascript max_value 
Javascript :: jquery append to table 
Javascript :: arry to object using reduce 
Javascript :: parse integer in javascript 
Javascript :: javascript online test 
Javascript :: groupBy angular 
Javascript :: mock an api call in jest 
Javascript :: javascript base64 decode 
Javascript :: make country flags in js 
Javascript :: react-native date time picker 
Javascript :: javascript random 1 or 0 
Javascript :: angular create library 
Javascript :: how to use platform.select 
Javascript :: timeout angularjs 
Javascript :: JavaScript for loop Display Sum of n Natural Numbers 
Javascript :: observable filter angular 8 
Javascript :: javascript fetch request GET 
Javascript :: accept 2 values after decimal in angular forms 
Javascript :: how to destructure props in react 
Javascript :: how to comments in json file 
Javascript :: cypress graphql request 
Javascript :: javascript sort associative array 
Javascript :: array includes 
Javascript :: mongodb find array which does not contain object 
Javascript :: react native get os 
Javascript :: react bootstrap sweetalert2 
Javascript :: ordenar un array de menor a mayor 
Javascript :: react-bootstrap example 
Javascript :: javascript console.table 
Javascript :: lodash clonedeep 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =