#fs.readdirSync throws, no such file or directory error

6 messages · Page 1 of 1 (latest)

quiet drum
#
const commandFiles = fs.readdirSync('./commands').filter((file: any) => file.endsWith('.ts'));
exotic oasis
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

quiet drum
#

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

misty jasper
# quiet drum

fs is based on the folder you run the script from… which judging by your code being ts probably isn’t that folder at all but somewhere the transpiled js resides

#

use path.join(_dirname, …) to get an absolute path to where the files actually are