Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ERR_UNSUPPORTED_ESM_URL_SCHEME] #3

Closed
igor53241 opened this issue Mar 19, 2023 · 1 comment
Closed

[ERR_UNSUPPORTED_ESM_URL_SCHEME] #3

igor53241 opened this issue Mar 19, 2023 · 1 comment
Labels
good first issue Good for newcomers

Comments

@igor53241
Copy link

Estou com o seguinte erro , [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file and data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol

@whoisdon whoisdon changed the title Erro esm [ERR_UNSUPPORTED_ESM_URL_SCHEME] Mar 20, 2023
@whoisdon
Copy link
Owner

Pelo que vi, esse erro ocorre na função import() do arquivo client.js, e não está sendo suportado. Você pode resolver passando o caminho por URL:

async loadCommands(path = 'src/Commands') {
    const categories = readdirSync(path);
    for (const category of categories) {
      const commands = readdirSync(join(path, category));
  
      for (const command of commands) {
        const commandFile = join(process.cwd(), path, category, command);
        const { default: CommandClass } = await import(`file://${commandFile}`);
        const cmd = new CommandClass(this);
        
        this.commandSlash.push(cmd);
      }
    }
  }

  async loadEvents(path = 'src/Events') {
    const eventsFolders = readdirSync(path);
    for (const folders of eventsFolders) {
      const eventsFiles = readdirSync(`${path}/${folders}`);
      for (const files of eventsFiles) {
        if (!files.endsWith('.js')) return;
        const eventFile = join(process.cwd(), path, folders, files);
        const { default: eventClass } = await import(`file://${eventFile}`);
        const evnt = new eventClass(this);
        if (!evnt.once) {
           this.on(evnt.name, evnt.run);
        } else {
           this.once(evnt.name, evnt.run);
        }
      }
    }
  }

@whoisdon whoisdon added the good first issue Good for newcomers label Sep 23, 2023
@whoisdon whoisdon pinned this issue Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants