Serverless Framework with AWS Lambda error "Cannot find module" Serverless Framework with AWS Lambda error "Cannot find module" node.js node.js

Serverless Framework with AWS Lambda error "Cannot find module"


Did you npm install in your working directory before doing your serverless deploy? The aws-sdk node module is available to all lambda functions, but for all other node dependencies you must install them so they will be packaged with your lambda when you deploy.

You may find this issue on the serverless repository helpful (https://github.com/serverless/serverless/issues/948).


I fixed this error when in package.json I moved everything from devDependencies to dependencies.

Cheers


I don't if it applies to this answer but in case someone just needs a brain refresh I forgot to export my handler and was exporting the file with was looking for a default export that didn't exist...

changed from this...handler: foldername/exports

to this...handler: foldername/exports.handler