Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

212
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda