#Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data are supported

2 messages · Page 1 of 1 (latest)

small citrus
#

Hi everyone,

I'm trying to read all commands from my command's folder but I can't seem to get it to work.

const commands = [];
const cwd = process.cwd();
const commandsDir = join(cwd, './src/Commands');

for (const file of readdirSync(commandsDir)) {
  const { default: Command } = await import(join(commandsDir, file));
  commands.push(Command.data.toJSON());
  client.commands.set(Command.data.name, Command);
}```

Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'd:'

any help would be appreciated
pine galleon
#

• 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.