【问题标题】:index.handler is undefined or not exported AWSindex.handler 未定义或未导出 AWS
【发布时间】:2021-10-29 20:36:09
【问题描述】:

我有一个 index.js 并且定义了处理函数。但是当我测试时,我得到了错误index.handler is undefined or not exported。知道如何解决这个问题吗?

{
  "errorType": "Runtime.HandlerNotFound",
  "errorMessage": "index.handler is undefined or not exported",
  "trace": [
    "Runtime.HandlerNotFound: index.handler is undefined or not exported",
    "    at Object.module.exports.load (/var/runtime/UserFunction.js:144:11)",
    "    at Object.<anonymous> (/var/runtime/index.js:43:30)",
    "    at Module._compile (internal/modules/cjs/loader.js:999:30)",
    "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)",
    "    at Module.load (internal/modules/cjs/loader.js:863:32)",
    "    at Function.Module._load (internal/modules/cjs/loader.js:708:14)",
    "    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)",
    "    at internal/main/run_main_module.js:17:47"
  ]
}

Function Logs
START RequestId: fa81b4c8-23f6-4f15-899b-dfc680ae9c57 Version: $LATEST
2021-10-29T08:47:21.477Z    undefined   ERROR   Uncaught Exception  {"errorType":"Runtime.HandlerNotFound","errorMessage":"index.handler is undefined or not exported","stack":["Runtime.HandlerNotFound: index.handler is undefined or not exported","    at Object.module.exports.load (/var/runtime/UserFunction.js:144:11)","    at Object.<anonymous> (/var/runtime/index.js:43:30)","    at Module._compile (internal/modules/cjs/loader.js:999:30)","    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)","    at Module.load (internal/modules/cjs/loader.js:863:32)","    at Function.Module._load (internal/modules/cjs/loader.js:708:14)","    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)","    at internal/main/run_main_module.js:17:47"]}
2021-10-29T08:47:22.789Z    undefined   ERROR   Uncaught Exception  {"errorType":"Runtime.HandlerNotFound","errorMessage":"index.handler is undefined or not exported","stack":["Runtime.HandlerNotFound: index.handler is undefined or not exported","    at Object.module.exports.load (/var/runtime/UserFunction.js:144:11)","    at Object.<anonymous> (/var/runtime/index.js:43:30)","    at Module._compile (internal/modules/cjs/loader.js:999:30)","    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)","    at Module.load (internal/modules/cjs/loader.js:863:32)","    at Function.Module._load (internal/modules/cjs/loader.js:708:14)","    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)","    at internal/main/run_main_module.js:17:47"]}
END RequestId: fa81b4c8-23f6-4f15-899b-dfc680ae9c57
REPORT RequestId: fa81b4c8-23f6-4f15-899b-dfc680ae9c57  Duration: 1463.33 ms    Billed Duration: 1464 ms    Memory Size: 128 MB Max Memory Used: 11 MB  
Unknown application error occurred
Runtime.HandlerNotFound

Request ID
fa81b4c8-23f6-4f15-899b-dfc680ae9c57

【问题讨论】:

    标签: node.js amazon-web-services aws-lambda


    【解决方案1】:

    Lambda 函数尚不支持 ES6 风格 (https://docs.aws.amazon.com/lambda/latest/dg/nodejs-handler.html)

    你应该使用:

    exports.handler =  async function(event, context) {
    }
    

    【讨论】:

      猜你喜欢
      • 2021-03-03
      • 2021-06-25
      • 2021-10-22
      • 2020-06-25
      • 2017-12-12
      • 2018-03-16
      • 2017-09-14
      • 1970-01-01
      • 2017-11-17
      相关资源
      最近更新 更多