Nodejs FS module returning no such file or dir error

后端 未结 1 454
心在旅途
心在旅途 2021-01-21 11:34

Code:

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

Error:

ENOENT: no such file or directory,

相关标签:
1条回答
  • 2021-01-21 11:59

    try with __dirname:

    fs.readdir(__dirname +'/commands/', (err, files) => {
    // Do something... 
    })
    
    0 讨论(0)
提交回复
热议问题