Reputation: 11
I am trying to add email to a firebase cloud function. However, when ever I add the line:
const nodemailer = require('nodemailer');
to index.js, code which previously deployed will no longer deploy. It reports that one of my functions had an error, but this can't be the case cause it works just fine with that function. Here is the full code, runs without the line just fine.
'use strict';
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const nodemailer = require('nodemailer');
admin.initializeApp();
exports.routineKick = functions.pubsub
.schedule('every 2 minutes')
.timeZone('America/New_York')
.onRun(context => {
//kickMembers();
}
);
Upvotes: 1
Views: 306
Reputation: 972
I'm using node mailer version of 6.7.0, In the "package.JSON" file, downgrade node version from 14 to 10 works for me
"engines": {
"node": "10"
},
"main": "index.js",
"dependencies": {
"firebase-admin": "^9.8.0",
"firebase-functions": "^3.14.1",
"nodemailer": "^6.7.0"
},
Upvotes: 0
Reputation: 5819
Posting the solution as a Community Wiki since this solution was shared by an edit to the question itself by the OP.
The problem is that the app was missing the nodemailer dependency. It can be fixed by doing the following:
In the package.JSON file, located at the functions folder, add under dependencies
the following: "nodemailer": "^6.4.3"
or whatever version you have.
Upvotes: 1