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
EXPERTE
gefragt vor 7 Monaten26 Aufrufe
1 Antwort
0

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

profile picture
EXPERTE
beantwortet vor 7 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen