Error: ENOENT: no such file or directory

Hi i am having the problem, (se eimage underneath) for a bit of time. To me it is clear that the direcory exists.
My fs.readdir should work fine, since it does so with recipes and writing, but not art. <–Files
I have no other errors, and honestly I just don’t know how to fix this, also it is my first time “hosting” a bot like this. Though this have not worked for me for weeks, I thought it was time to go all you experts, sicne I cannot find the solution myself.

I have this project, where I host a discord bot for my server, and it works fine. All commands work etc. expect i get this “funny” error. I hope someone can help.


Thank you ~ Kellany

If you take a closer look at the error you’ll see that it’s trying to get ./commands/art which doesn’t really exist. It should instead be searching for ./commands/art.js. This leads me to assume that something is wrong with your command handler.

Hmm I tried to add .js after, but it still gives the same error. As you can see in my image posted below, that nothing is wrong with all the other fs.readdir’s, and I have 8, only one won’t work. The one in question is the 6th.

Umm, you are trying to read a directory as I could see:


But your path is going to a file (.../art.js)


Steps to fix

  1. Make folders with the commands inside
  2. Make 2 fs.readdir calls for cycling through
    a) commands folders
    b) commands in these folders

You can do that with the following code:

fs.readdirSync(COMMANDS_PATH).forEach(group => {
  fs.readdirSync(COMMANDS_PATH + group).forEach(commandName => {
    const command = require('.' + COMMANDS_PATH + group + '/' + commandName).command = group = commandName.split('.')[0]

    // Store your command file info

Hope it helps!

1 Like

Instead of ./commands/art.js replace the ./ with /app/.

If this doesn’t work check out other peoples answers (up and bellow)!

Happy Glitching!

Hey @Kellany it might be worthwhile to see your full directory structure. Even better if you can share your project name.

I have solved it.
It turns out that it is because I didn’t know how to make folders properly on here.
Once i made the folder the right way (after figuring out how to do so) the problem were gone.

Thank you for your suggestion and help!


Please I beg you I have the same problem TELL me how do u do it???

Hi @Jayraj_Sinvhal, welcome to the Glitch community :slight_smile:

It would help if you could post the full error like the original poster did above, then we can see exactly what file your code is trying to load, and what the error is.

If you have a public project name, that can be very helpful too, so we can check your code.

You might notice this thread is 2 years old – in future it’s best to start a new topic with your problem instead of posting in the older one :blush:

Hope we can help you!