Проверка существования файла

Файлы / Базовые операции

//через Node.js
//npm i @types/node
const fs = require("fs")

let filePath = "file.txt"

//Асинхронно:
fs.exists(filePath, (exists: boolean) => { 
    if (exists) { 
        console.log("File exist!")
    } 
})

//Синхронно:
if (fs.existsSync(filePath)) { 
    console.log("File exist!")
}