'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:

      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.

Solution 1:[1]

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


This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 prince Arthur