Home Articles

Solved! ENOTEMPTY: Directory not empty

Sep 1, 2021 ∘ Yoko Ishioka
Broken robot

I recently redesigned my blog's website and set up the upload process so that I wasn't dragging files to be uploaded directly from Visual Studio Code. As a result, I started getting this error each time I tried to build the site:

An unhandled exception occurred: ENOTEMPTY: directory not empty, rmdir...

Since I'm using Angular, I noticed that the 'dist' folder (the one Angular publishes your build to) was deleting my assets but not the actual folder like it used to. I found a couple of Stack Overflow threads that offered solutions to bypass this error. Deleting the nodes_modules folder and reinstalling express body parser worked once but the error kept coming back on subsequent builds.

It turns out that the problem wasn't a permissions one which I initially suspected. It was acutally quite simple...I just had a finder window open with that directory! Anyway, just thought I'd share since it was such a stupid mistake.

To resolve the error, all you have to do is close any dialogs that have the 'dist' folder open. Whoops!