Search code examples
node.jslambdanode-modulesserverless

Deploy nodejs lambda by serverless met layer size exceeded error


I want to deploy my aws lambda by serverless, the repo is here: https://github.com/Jeff-Tian/serverless-space.

Basically it's a nest serverless app, and I configured my serverless.yml to use layer manager so I can put my node_modules into that layer.

I installed the production-only node_modules so the size is only 93M. But if I ran serverless deploy then the error occurs, claiming my unzipped size exceeds 250M.

Then I checked my node_moudles size again by du -h -d 0 node_modules, it shows it's 400+ M now.

So I guess the serverless deploy installed extra packages to my node_modules, and can be fixed by install serverless plugins globally. But unfortunately there is no this kind of option: https://github.com/serverless/serverless/issues/3319#issuecomment-303080193.

Can anyone shed some lights here?

Thanks in advance!


Solution

  • Currently can workaround it by

    npm install -g serverless
    npm install -g serverless-plugin-names
    
    serverless deploy