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

1 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