I'm using this piece of code to delete a file on demand
fs.access(path, (err)=> err || fs.unlink(path));
Error: ENOENT: no such file or directory, unlink 'C:\ ... '
at Error (native)
calling fs.access before write or delete is not recommended. Please check the below link https://nodejs.org/api/fs.html#fs_fs_access_path_mode_callback
Using fs.access() to check for the accessibility of a file before calling fs.open(), fs.readFile() or fs.writeFile() is not recommended. Doing so introduces a race condition, since other processes may change the file's state between the two calls. Instead, user code should open/read/write the file directly and handle the error raised if the file is not accessible.