从AWS Lambda发送SES电子邮件-节点JS错误“找不到模块'nodemailer'"; [英] Sending SES email from AWS Lambda - Node JS Error "Cannot find module 'nodemailer"

查看:254
本文介绍了从AWS Lambda发送SES电子邮件-节点JS错误“找不到模块'nodemailer'";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下错误消息:"errorMessage":找不到模块'nodemailer'"

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

我用Google搜索,并说安装nodemailer.有人可以告诉我该模块的确切安装位置吗?我是Lambda的新手.

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

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

这篇关于从AWS Lambda发送SES电子邮件-节点JS错误“找不到模块'nodemailer'";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆