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

213
Vistas
Why I am getting this error: declares '<MODULE>' locally, but it is not exported

I have a typescript file which exports a function to send emails using aws ses

//ses.tsx
let sendEmail = (args: sendmailParamsType) => {
    let params = {
    //here I get the params from args, then I send the email
    };
    return AWS_SES.sendEmail(params).promise();
};
module.exports = {
    sendEmail
};

then somewhere else I have a next.js API endpoint page importing the module like this

//index.tsx
import {sendEmail} from "../../../lib/ses";

the path is correct but the editor (phpstorm) highlight that line above in red and the error message is

declares 'sendEmail' locally, but it is not exported.

The path is correct and as you can see the module is exported. When I execute the page I don't get any error but the email is not sent.

Also, I use the same module from another endpoint and it works. Any suggestion to solve or debug this?

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

0

You're mixing up ES with CommonJS.

module.exports is used with require() //CommonJS Syntax

export is used with import //ES Syntax.

you can either export all the objects at once

Oor you can simple export the object directly.

Mail.tsx:

export const sendEmail = () => {}

main.tsx

import {sendEmail} from "./Mail";

Also I recommend to use const instead of let for functions.

export default ...

also works, but may be used one time per file and can be imported with

import Mail from "./Mail.tsx";
Mail.sendEmail(...);
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