Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

199
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!