简体   繁体   中英

Sending SES email from AWS Lambda - Node JS Error “Cannot find module 'nodemailer”

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');
};
  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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM