Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js check file exist

import fs from 'fs';

const path = './file.txt';

try {
  if (fs.existsSync(path)) {
    //file exists
  }
} catch(err) {
  console.error(err);
}
 
PREVIOUS NEXT
Tagged: #js #check #file #exist
ADD COMMENT
Topic
Name
2+4 =