简体   繁体   English

从AWS Lambda发送SES电子邮件-节点JS错误“找不到模块'nodemailer”

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

I have this error message: "errorMessage": "Cannot find module 'nodemailer'" 我收到此错误消息:“ errorMessage”:“找不到模块'nodemailer'”

I Googled, and it says install nodemailer. 我用Google搜索,并说安装nodemailer。 Can someone tell me where exactly do I install this module? 有人可以告诉我该模块的确切安装位置吗? I am new to Lambda. 我是Lambda的新手。

My Lambda function is below : 我的Lambda函数如下:

    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 您必须在本地初始化项目npm init
  2. Install nodemailer - npm i nodemailer 安装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. 您应该压缩项目目录,然后通过在功能代码窗口中选择上载.ZIP文件将其上载到lambda。
  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. 只需将所有代码放入index.js进行初始测试,以后就可以随意移动它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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