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

匿名 (未验证) 提交于 2019-12-03 01:25:01

问题:

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:

  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.


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!