Here is an example using `fs.stat`, but handling errors correctly as well:
```js
async function fileExists(filename) {
try {
await fs.promises.stat(filename);
return true;
} catch (err) {
if (err.code === 'ENOENT') {
return false;
} else {
throw error;
}
}
}
```
Here is an example using `fs.stat`, but handling errors correctly as well:
```js
async function fileExists(filename) {
try {
await fs.promises.stat(filename);
return true;
} catch (err) {
if (err.code === 'ENOENT') {
return false;
} else {
throw error;
}
}
}
```