AWS lambda function error – Unable to import module ‘index’: Error

Unable to import module ‘index’: Error

It looks like some of your dependencies are installed / not packaged correctly. Delete the node_modules directory and re-install the module with npm install should fix the issue.

Make sure your function get packaged as mentioned in the doc https://docs.aws.amazon.com/lambda/latest/dg/nodejs-create-deployment-pkg.html

If your bundle missed a node_module, then it will result in this error.

EDIT1:

You got an issue with gulp packaging.

The following example has the complete documentation for packaging lambda with gulp.

https://medium.com/@AdamRNeary/a-gulp-workflow-for-amazon-lambda-61c2afd723b6

Hope it helps.

Leave a Comment