13

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.

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. Commented May 13, 2016 at 15:18
  • 1
    I knew it would be simple. A million thanks! Commented May 13, 2016 at 15:19

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

FYI the AWS Lambda JS runtime didn't support async/await until April 2018, 2 years after this question was originally asked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.