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 :: angular create spec file for existing component 
Javascript :: how to change css of menu when scrolling 
Javascript :: How to append variable with anchor element href link in Angularjs 
Javascript :: How to add ui-scroll with remote data in angularjs 
Javascript :: how to replace img url using jquery on mobile screen 
Javascript :: Angularjs to Angular Migration: factory prototype 
Javascript :: angularjs How do I show all indicators for carousel in an ng-repeat 
Javascript :: How do I pass the contents of a textbox into angular js as an input parameter, rather than a $scope variable 
Javascript :: inserting new value to an array of object in typescript 
Javascript :: EXPO useEffect not called on navigating to same screen 
Javascript :: javascript unique grouped arrays 
Javascript :: socket io check send 
Javascript :: chain underscore 
Javascript :: fetch 500 internal server error 
Javascript :: Node.js with Express: Importing client-side javascript using script tags in Jade views 
Javascript :: debouce with clear debounce function javascript 
Javascript :: react text editor snippet 
Javascript :: Odoo Javascript Modules 
Javascript :: Create A Class Using JavaScript 
Javascript :: switching light bulbs problem javascript 
Javascript :: Declare Function In Class Constructor 
Javascript :: reduxjs toolkit createaction 
Javascript :: css to jss 
Javascript :: checkbox null value javascript 
Javascript :: javascript call function change last default value 
Javascript :: javascript remove the second to last character of a string 
Javascript :: js filter out html 
Javascript :: recursive function and json object 
Javascript :: How many options are there to climb a ladder with N 
Javascript :: java script return array 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =