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

177
Vistas
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 Respuestas
Responde la pregunta

0

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

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