const fs = require("fs/promises");
const path = require("path");
const filePath = path.join(thumbDir, fileName);
try {
await fs.unlink(filePath);
console.log("File deleted successfully");
} catch (err) {
if (err.code === "ENOENT") {
console.log("File not found, nothing to delete");
} else {
throw err;
}
}
Sign up here with your email
ConversionConversion EmoticonEmoticon