Search code examples
aws-lambdaaws-cli

Index handler is undefined or not exported


I have a lambda function which was working fine but I wanted to import a package so I created a directory with index.js and installed my npm package.

Then created a zip of this folder and uploaded it using

aws lambda update-function-code --function-name smrtfac-test --zip-file fileb://lambda.zip

But now I am getting this error

index.handler is undefined or not exported

What could be the reason for it? my index.js and node_modules are in the same directory.


Solution

  • This usually occurs when you zip up the directory, instead of zipping up the contents of the directory. When you open your zip file to browse the content, the index.js file should be in the root of the zip file, not in a folder.