A quick pro-tip for handling this situation.
NodeJS provides an easy to use
fs.rmdir command that follows the POSIX standard. This unfortunately means that it will error ENOTEMPTY if there is any file in the directory you are attempting to remove. NodeJS doesn’t have an easy way to force the removal, so you have to get fancy.
It’s 2018, use del.
Or if you must, try trash. It’s really neat too.