Answers for "nodejs fs remove file"

7

nodejs fs delete file

const fs = require('fs')

const path = './file.txt'

try {
  fs.unlinkSync(path)
  //file removed
} catch(err) {
  console.error(err)
}
Posted by: Guest on February-10-2021
5

delete with unlinksync node

const fs = require('fs')

const path = './file.txt'

try {
  fs.unlinkSync(path)
  //file removed
} catch(err) {
  console.error(err)
}
Posted by: Guest on July-02-2020
1

delete file using node javascript

var fs = require('fs');

fs.unlink('mynewfile2.txt', function (err) {
  
  if (err) throw err;
  console.log('File deleted!');
});
Posted by: Guest on July-18-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language