Cannot find module:’@algolia/cache-common'”

When you “install” dependencies like @algolia/cache-common you are installing them locally.

Your installed dependencies are not automatically available on AWS Lambda. Like your application code, your dependencies need to be deployed as well.

That’s why it works on your local machine but not in Lambda.

You did not write anything on how you deploy your code. Tools like AWS SAM or the serverless framework usually take care of not only deploying your application code but also it’s dependencies.

So I imagine you are deploying by hand. That means that you most likely will have to also deploy your node_modules folder to AWS Lambda.

Your deployment ZIP archive should look like this:


The node_modules folder will have a lot of sub-folders etc and obviously, you can have more than one .js file. But for the purpose of this post we leave it at that.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top