4

Code:

fs.readdir('./commands/', (err, files) => {
     // Do something... 
});

Error:

ENOENT: no such file or directory, scandir './commands/'

The folder ./commands/ does exist. This file is src/index.js and is trying to read the directory of src/commands/. It wouldn't be fs.readdir('/commands' because that would be referring to the root directory of my PC (Ubuntu 18.04 LTS, Node version v8.10.0). If any further information is required, ask and I will provide it.

Thank you all in advance.

kgangadhar
  • 4,886
  • 5
  • 36
  • 54

1 Answers1

5

try with __dirname:

fs.readdir(__dirname +'/commands/', (err, files) => {
// Do something... 
})
crellee
  • 855
  • 1
  • 9
  • 18