最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - node-lambda - TypeError: handler is not a function - Stack Overflow

programmeradmin2浏览0评论

New to AWS and found it quite straightforward so far but really getting stuck packaging a lambda function.

I'm using node-lambda to try and run the function but keep getting the following error on node-lambda run:

/usr/local/lib/node_modules/node-lambda/lib/main.js:93
      handler(event, context, callback);
      ^

TypeError: handler is not a function
    at Lambda._runHandler (/usr/local/lib/node_modules/node-lambda/lib/main.js:93:7)
    at Lambda.run (/usr/local/lib/node_modules/node-lambda/lib/main.js:49:8)
    at Command.<anonymous> (/usr/local/lib/node_modules/node-lambda/bin/node-lambda:89:12)
    at Command.listener (/usr/local/lib/node_modules/node-lambda/node_modules/mander/index.js:301:8)

New to AWS and found it quite straightforward so far but really getting stuck packaging a lambda function.

I'm using node-lambda to try and run the function but keep getting the following error on node-lambda run:

/usr/local/lib/node_modules/node-lambda/lib/main.js:93
      handler(event, context, callback);
      ^

TypeError: handler is not a function
    at Lambda._runHandler (/usr/local/lib/node_modules/node-lambda/lib/main.js:93:7)
    at Lambda.run (/usr/local/lib/node_modules/node-lambda/lib/main.js:49:8)
    at Command.<anonymous> (/usr/local/lib/node_modules/node-lambda/bin/node-lambda:89:12)
    at Command.listener (/usr/local/lib/node_modules/node-lambda/node_modules/mander/index.js:301:8)

My index.js file has the handler declared like so

exports.myHandler = function(event, context) {

And the AWS_HANDLER in my .env is set to index.handler. I eel like I'm missing an obvious step.

Share Improve this question asked May 13, 2016 at 15:13 Richard AskewRichard Askew 1,2371 gold badge10 silver badges16 bronze badges 2
  • 18 You've named it myHandler. You either need to name it handler or change the name that you are telling Lambda to look for. – Mark B Commented May 13, 2016 at 15:18
  • 1 I knew it would be simple. A million thanks! – Richard Askew Commented May 13, 2016 at 15:19
Add a ment  | 

1 Answer 1

Reset to default 2

use exports.handler = async function(event, context) { instead of exports.myHandler = function(event, context) {

发布评论

评论列表(0)

  1. 暂无评论