Answers for "nodejs check string is present in file"

26

node check if file exists

const fs = require("fs"); // Or `import fs from "fs";` with ESM
if (fs.existsSync(path)) {
    // Do something
}
Posted by: Guest on May-22-2020
1

search string in file node

fs.readFile(FILE_LOCATION, function (err, data) {
  if (err) throw err;
  if(data.includes('search string')){
   console.log(data)
  }
});
Posted by: Guest on April-21-2020

Code answers related to "nodejs check string is present in file"

Code answers related to "Javascript"

Browse Popular Code Answers by Language