Lambda函数 HandlerNotFound 错误

0

【以下的问题经过翻译处理】 我创建了一个用于图像调整大小的Lambda函数(Node.js)。我收到了Runtime.HandlerNotFound的错误消息。

Cloudwatch日志如下:

2022-07-15T01:06:22.016Z undefined ERROR Uncaught Exception {
"errorType": "Runtime.HandlerNotFound",
"errorMessage": "index.handler is undefined or not exported",
"stack": [
"Runtime.HandlerNotFound:index.handler未定义或未导出",
" at Object.module.exports.load (/var/runtime/UserFunction.js:283:11)",
" at Object.<anonymous> (/var/runtime/index.js:43:34)",
" at Module._compile (internal/modules/cjs/loader.js:1085:14)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)",
" at Module.load (internal/modules/cjs/loader.js:950:32)",
" at Function.Module._load (internal/modules/cjs/loader.js:790:12)",
" at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)",
" at internal/main/run_main_module.js:17:47"
]
}

我的Index.js部分如下:

'use strict';


const querystring = require('querystring'); // 不需要安装。
const AWS = require('aws-sdk'); // 不需要安装。


// <http://sharp.pixelplumbing.com/en/stable/api-resize/>
const Sharp = require('sharp');


const S3 = new AWS.S3({
region: 'ap-northeast-2' //
});


const BUCKET = 'BUCKET_NAME' // 输入您的bucket


// 可以通过Sharp处理的图像类型
const supportImageTypes = ['jpg', 'jpeg', 'png', 'gif', 'webp', 'svg', 'tiff', 'jfif'];


exports.handler = async(event, context, callback) => {
const { request, response } = event.Records[0].cf;


console.log("request: ", request)
console.log("response: ", response)
profile picture
专家
已提问 5 个月前17 查看次数
1 回答
0

【以下的回答经过翻译处理】 你能确认handler 的路径和index文件的路径是否相同吗? 当handler路径和打包中index.js的位置不同时,就会出现此错误。

profile picture
专家
已回答 5 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则