how to check file exists on path in javascript code example
Example: js check file exist
import fs from 'fs';
const path = './file.txt';
try {
if (fs.existsSync(path)) {
//file exists
}
} catch(err) {
console.error(err);
}
import fs from 'fs';
const path = './file.txt';
try {
if (fs.existsSync(path)) {
//file exists
}
} catch(err) {
console.error(err);
}