Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

180
Vistas
SyntaxError: Unexpected reserved word "await"

I keep getting this error even thought I am in a asynchronous function...

import { dirname, join } from "path";
import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

export async function importer(client) {
    const dir = join(__dirname, "../../commands/")

    const commandCategories = readdirSync(dir)
    for (let cat of commandCategories) {
        const commandFiles = readdirSync(join(dir, cat)).filter(files => files.endsWith(".js"));

        for (const file of commandFiles) {
            const command = await import(join(dir, cat, file));
            client.commands.set(command.default.name, command.default);
        }
    }
}

Is there something I am missing? I definitely need the await part in import in const command. It imports a few commands then it drops the mentioned error in title on the console output.

Thanks.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The problem isn't the importer code, it's in one of the modules you attempted to import (and import crashes on parsing it)!

It's a bug in node that such a non-helpful error is thrown when this syntax error is encountered during dynamic import.

Try logging the filenames before importing them so you can see at which file it crashes. Once you know which file failed to parse, do a static import of it for testing, so you can get a proper error that tells you which line has the issue.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda