Nodejs FS module returning no such file or dir error

后端 未结 1 453
心在旅途
心在旅途 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)
提交回复
热议问题