0

I have this error message: "errorMessage": "Cannot find module 'nodemailer'"

I Googled, and it says install nodemailer. Can someone tell me where exactly do I install this module? I am new to Lambda.

My Lambda function is below :

    var aws = require("aws-sdk");
var nodemailer = require("nodemailer");

var ses = new aws.SES();
var s3 = new aws.S3();

exports.handler = (event, context, callback) => {
callback(null, 'Hello from Lambda');
};
3
  • You should install module nodemailer in your local, then copy all files and input to lambda Commented Sep 28, 2018 at 3:26
  • I am using Windows desktop machine. Should I install nodemailer on my Windows desktop and then copy all files and input to Lambda? How do I copy files into Lambda? I thought Lambda is only for writing code, and no storage. Could you please give me an example? or step by step guide to do this? THank you. Commented Sep 28, 2018 at 8:33
  • you need to package your code with appropriate dependencies and deploy it on lambda using ZIP. More details you can get here: docs.aws.amazon.com/lambda/latest/dg/… Commented Sep 28, 2018 at 9:18

1 Answer 1

2
  1. You'll have to initialize your project locally npm init
  2. Install nodemailer - npm i nodemailer
  3. You should zip your project directory, upload it to lambda by selecting Upload a .ZIP file in the function code window.
  4. Now you'll get an option to test.
  5. Just put all the code in index.js for your initial tests, later you can move it around.
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks bro for the detailed steps, it really worked for me :) Glad to set up my first Lambda function. I am trying to send out a test email when a SQS message arrives. Hope I can do it
I changed to an Ubuntu local server and did all the above steps 1-4. Step 5 done on AWS Web console

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.