Excluding Dev Dependencies also deleting necessary modules

Hello guys, please help me out here. This is an issue happening for us for a while now.

When we choose to excludeDevDependencies: true, there are also some necessary modules being deleted from the deployed package. What happens is that our lambda function, after deployment, keeps logging the message
"ERROR Uncaught Exception {"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module <some-module>"} "

We tried to simply skip the excluding step by excludeDevDependencies: false. However this generates a package too large to be deployed in a lambda function.

Does anyone have an idea here?

FYI: we use yarn instead of npm. Don’t know if it changes anything, I believe it shouldn’t.

Thanks in advance!

Hi, so move the necessary module from "devDependencies" to "dependencies" in package.json. I think that that could solve it.

You should take a look at this plugin

It will bundle you lambda in a single file with only the required xeps. Smaller size and faster coldstart…