I am trying to accomplish a simple task, Delete a file. The error really doesn't tell me why it cannot delete the file. Any ideas on what it can be and how I can find out more of a detailed error in the future?
My Code:
var fs = require('fs');
fs.unlink('/file/path.jpg', function(err){
if (err) throw err;
});
My Error:
DEBUG:
DEBUG: /Users/vartanarabyan/Development/NodeJS/orcha/routes/document.js:67
DEBUG: if (err) throw err;
DEBUG: ^
DEBUG: Error: ENOENT, unlink '/Users/vartanarabyan/Development/NodeJS/orcha/public/uploads/5d78abfefd5ff47398103ada55d9be47'
DEBUG: Program node app exited with code 1
ENOENT
means No such file or directory
. You are trying to delete a file that doesn't exist.
ok fixed the problem by using fs.unlinkSync(path)