Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node-lambda - TypeError: handler is not a function

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/commander/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.

like image 397
Richard Askew Avatar asked Mar 01 '26 00:03

Richard Askew


1 Answers

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

like image 128
prince Arthur Avatar answered Mar 03 '26 12:03

prince Arthur



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!