Answers for "delete file using fs node js"

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
5

how to create a server in node js

// code by VARSHITH REDDY SATTI
// to create a server in node.js you should.
var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/html'});
  res.write("write html code to display you test")
  res.end();
}).listen(8080);
// save this as httpServer.js
// run this by typing node httpServer.js in the command line
// to acess your server got to http://localhost:8080
Posted by: Guest on December-28-2019
1

writefile in node js

fs.writeFile('2pac.txt', 'Some other lyric', 'ascii', callback);
Posted by: Guest on March-15-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language