//使用 Node.js
//npm i @types/node
const fs = require("fs");
let filePath = "file.txt";
//异步方式:
fs.access(filePath, fs.constants.F_OK, (err) => {
if (!err) {
console.log("File exist!");
}
});
//同步方式:
if (fs.existsSync(filePath)) {
console.log("File exist!");
}