本文介绍了错误:ENOENT:没有此类文件或目录,请取消链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如您所见,路径中有一个文件.但是fs说没有这样的文件或目录.我不明白为什么?
As you can see, there is a file at the path. But fs says no such file or directory. I can't understand why?
在另一个文件中,我可以使用相同的代码删除.
In another file, I can remove with the same code.
我的boat.js文件:
My boat.js file:
boat.findById(req.params.id,function(err, foundBoat) { if(err){ console.log(err); }else{ foundBoat.boatsFoto.forEach(function(path){ console.log(typeof(path)); fs.unlink("../public"+path,function(err){ if(err) throw err; console.log('File deleted!'); }); }); } });这是我的错误:
Error: ENOENT: no such file or directory, unlink '../public/uploads/akingokay/BoatsFoto/1524411110335kiralik-tekne.jpg' at Error (native)您可以看到我的文件系统
推荐答案您可以尝试以下方法吗?
Can you try this instead:
fs.unlink("public"+path,function(err){ if(err) throw err; console.log('File deleted!'); });更多推荐
错误:ENOENT:没有此类文件或目录,请取消链接
发布评论