问题
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
- Install nodemailer -
npm i nodemailer
- You should zip your project directory, upload it to lambda by selecting Upload a .ZIP file in the function code window.
- Now you'll get an option to test.
- Just put all the code in
index.js
for your initial tests, later you can move it around.
来源:https://stackoverflow.com/questions/52547763/sending-ses-email-from-aws-lambda-node-js-error-cannot-find-module-nodemaile