I am trying to delete directory using fs
module from node.js but as per my current code its throwing the following error.
Error:
Error:: { Error: ENOTEMPTY: directory not empty, rmdir '/app/uploads'
at Object.rmdirSync (fs.js:684:3)
at Object.usecaseWorkflow (/app/controller/usecaseWorkflowCtrl.js:97:32)
at process._tickCallback (internal/process/next_tick.js:68:7)
errno: -39,
syscall: 'rmdir',
code: 'ENOTEMPTY',
path: '/app/uploads' }
I am explaining my code below.
if (fs.existsSync(`${process.env['root_dir']}/uploads`)) {
fs.rmdirSync(`${process.env['root_dir']}/uploads`, {
recursive: true,
});
}
Here I am trying to delete uploads
directory present inside root directory but getting that error and also unable to delete. I am using node.js version 10
. Can anybody help me to resolve this issue so that I can delete the directory successfully ?