Error: ENOTDIR: not a directory, scandir error on file that shouldn’t be read

I’m trying to read from only the Commands folder but get an error from my Events folder.
I use the following code to read the Commands folder:

const commands = readdirSync(`./Commands/${dir}`).filter(file => file.endsWith('.js'));

but I still get the following error:

Error: ENOTDIR: not a directory, scandir './Events/interactionCreate.js'