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

175
Views
firebase functions, cant resolve module?

Im having an annoying problem which i've spent most of my day trying to solve without any luck - Also tried searching for a solution here and on Google, but without any luck, or at least all solution tried out didn't work.

When running my function, the firebase function log is telling me:

Cannot find module 'mailgun.js'

I have no idea why it won't resolve the module as it exist in the package.json file.

From the package.json:

"dependencies": {
    "cors": "^2.8.5",
    "firebase-admin": "^9.8.0",
    "firebase-functions": "^3.14.1",
    "form-data": "^4.0.0",
    "mailgun.js": "^4.1.4"
  },

I've have done a npm install inside the functions folder, and it deploys without problems, so the problem is when calling the function...

The code is:

import * as functions from "firebase-functions";
import Mailgun from "mailgun.js";
// eslint-disable-next-line @typescript-eslint/no-var-requires
const formData = require("form-data");

const domain = "https://app.mailgun.com/app/sending/domains/sandboxae7cd087b3854d25a6933f1fe489b5e3.mailgun.org";
const mgClient = new Mailgun(formData);

const mg = mgClient.client({
  key: "mykey",
  username: "api",
  public_key: "mypublickey",
});

export const sendWelcomeEmailToClient = functions.https.onCall(
    async (email: string) => {
      return mg.messages.create(domain, {
        from: "Task System",
        to: email,
        subject: "Testing",
        html: "Dette er en test",
      });
    }
);

Please note, i've also tried doing a require instead of import on mailgun.js like so, but didn't work either: Also, the mailgun documentation says that is the way to import it: https://www.npmjs.com/package/mailgun.js

const Mailgun = require("mailgun.js");
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Solved it by using SendGrid instead of MailGun, that works as a charm...

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!